#!/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()