mirror of
https://github.com/vinta/awesome-python.git
synced 2026-03-23 13:56:43 +08:00
build: simplify Makefile targets and add live-reload preview
Rename site_* targets to bare names (install, fetch_stats, build, preview). Replace the static preview target with a watchmedo-driven live-reload loop so file changes trigger automatic rebuilds. Make the output directory creation idempotent (exist_ok=True) and static copy incremental (dirs_exist_ok=True) so repeated builds don't wipe output on each run. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
22
Makefile
22
Makefile
@@ -1,17 +1,21 @@
|
|||||||
-include .env
|
-include .env
|
||||||
export
|
export
|
||||||
|
|
||||||
site_install:
|
install:
|
||||||
uv sync --no-dev
|
uv sync
|
||||||
|
|
||||||
site_fetch_stats:
|
fetch_stats:
|
||||||
uv run python website/fetch_github_stars.py
|
uv run python website/fetch_github_stars.py
|
||||||
|
|
||||||
site_build:
|
build:
|
||||||
uv run python website/build.py
|
uv run python website/build.py
|
||||||
|
|
||||||
site_preview: site_build
|
preview: build
|
||||||
python -m http.server -d website/output/ 8000
|
@echo "Check the website on http://localhost:8000"
|
||||||
|
uv run watchmedo shell-command \
|
||||||
site_deploy: site_build
|
--patterns='*.md;*.html;*.css;*.js;*.py' \
|
||||||
@echo "Deploy via GitHub Actions (push to master)"
|
--recursive \
|
||||||
|
--wait --drop \
|
||||||
|
--command='uv run python website/build.py' \
|
||||||
|
README.md website/templates website/static website/data & \
|
||||||
|
python -m http.server -b 127.0.0.1 -d website/output/ 8000
|
||||||
|
|||||||
@@ -220,9 +220,7 @@ def build(repo_root: str) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
site_dir = website / "output"
|
site_dir = website / "output"
|
||||||
if site_dir.exists():
|
site_dir.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.rmtree(site_dir)
|
|
||||||
site_dir.mkdir(parents=True)
|
|
||||||
|
|
||||||
tpl_index = env.get_template("index.html")
|
tpl_index = env.get_template("index.html")
|
||||||
(site_dir / "index.html").write_text(
|
(site_dir / "index.html").write_text(
|
||||||
@@ -241,7 +239,7 @@ def build(repo_root: str) -> None:
|
|||||||
static_src = website / "static"
|
static_src = website / "static"
|
||||||
static_dst = site_dir / "static"
|
static_dst = site_dir / "static"
|
||||||
if static_src.exists():
|
if static_src.exists():
|
||||||
shutil.copytree(static_src, static_dst)
|
shutil.copytree(static_src, static_dst, dirs_exist_ok=True)
|
||||||
(site_dir / "CNAME").write_text("awesome-python.com\n", encoding="utf-8")
|
(site_dir / "CNAME").write_text("awesome-python.com\n", encoding="utf-8")
|
||||||
|
|
||||||
print(f"Built single page with {len(categories)} categories + {len(resources)} resources")
|
print(f"Built single page with {len(categories)} categories + {len(resources)} resources")
|
||||||
|
|||||||
Reference in New Issue
Block a user