Download scripts/sync-requirements.py from Altisvc/day1demo: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/Altisvc/day1demo/resolve/main/scripts/sync-requirements.py
- Command line
-
hf download hf://spaces/Altisvc/day1demo/scripts/sync-requirements.py
-
curl -L -o sync-requirements.py https://huggingface.co/spaces/Altisvc/day1demo/resolve/main/scripts/sync-requirements.py
1.05 kB
| #!/usr/bin/env python3 | |
| """ | |
| Sync requirements.txt from pyproject.toml. | |
| This keeps requirements.txt in sync for Hugging Face Spaces deployment | |
| while using pyproject.toml as the source of truth. | |
| Usage: | |
| uv run python scripts/sync-requirements.py | |
| # or | |
| python scripts/sync-requirements.py | |
| """ | |
| import tomllib | |
| from pathlib import Path | |
| def main(): | |
| project_root = Path(__file__).parent.parent | |
| pyproject_path = project_root / "pyproject.toml" | |
| requirements_path = project_root / "requirements.txt" | |
| with open(pyproject_path, "rb") as f: | |
| pyproject = tomllib.load(f) | |
| dependencies = pyproject.get("project", {}).get("dependencies", []) | |
| if not dependencies: | |
| print("No dependencies found in pyproject.toml") | |
| return | |
| # Write requirements.txt (production deps only, not dev) | |
| with open(requirements_path, "w") as f: | |
| for dep in dependencies: | |
| f.write(f"{dep}\n") | |
| print(f"Synced {len(dependencies)} dependencies to requirements.txt") | |
| if __name__ == "__main__": | |
| main() | |