Download scripts/bundle_frontend.py from pollen-robotics/microduck-arena: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/pollen-robotics/microduck-arena/resolve/main/scripts/bundle_frontend.py
- Command line
-
hf download hf://spaces/pollen-robotics/microduck-arena/scripts/bundle_frontend.py
-
curl -L -o bundle_frontend.py https://huggingface.co/spaces/pollen-robotics/microduck-arena/resolve/main/scripts/bundle_frontend.py
1.17 kB
| #!/usr/bin/env python | |
| """Put the built site inside the package, so the wheel serves it. | |
| `npm run build` writes `app/dist` — the pages, the hashed bundle and everything | |
| in `app/public` (the meshes, the sounds, the stylesheets). Copied to | |
| `arena/frontend/`, hatchling ships it as a build artefact and `arena serve` or | |
| `workshop` finds it next to the code, wherever the package is installed. The | |
| release workflow runs this; the Dockerfile does the same with a `COPY` of the | |
| built dist to the same path. Nothing else writes that directory, and it is | |
| never committed. | |
| uv run python scripts/bundle_frontend.py | |
| """ | |
| import shutil | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| DIST = ROOT / "app" / "dist" | |
| TARGET = ROOT / "arena" / "frontend" | |
| def bundle(dist: Path = DIST, target: Path = TARGET) -> Path: | |
| if not (dist / "index.html").is_file(): | |
| print(f"{dist}: no index.html — run `npm run build` in app/ first", file=sys.stderr) | |
| sys.exit(2) | |
| if target.exists(): | |
| shutil.rmtree(target) | |
| shutil.copytree(dist, target) | |
| return target | |
| if __name__ == "__main__": | |
| print(f"bundled {bundle()}") | |