File size: 1,051 Bytes
9b32d94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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()