File size: 1,301 Bytes
045c645
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
"""Dry-run the Space's pip install so pin conflicts fail in CI, not on the Space."""

from __future__ import annotations

import subprocess
import sys
import tempfile
from pathlib import Path

import check_versions

ROOT = Path(__file__).resolve().parent.parent

# Mirrors the Space build log. Update these if the Space's install line changes.
SPACE_EXTRAS = ["torch<=2.13.0", "uvicorn>=0.14.0", "websockets>=10.4", "spaces==0.51.3"]


def main() -> int:
    python_version = (ROOT / ".python-version").read_text(encoding="utf-8").strip()
    lines = [f"gradio[oauth,mcp]=={check_versions.gradio_pin()}", *SPACE_EXTRAS]
    with tempfile.TemporaryDirectory() as tmp:
        extras = Path(tmp) / "space_extras.txt"
        extras.write_text("\n".join(lines) + "\n", encoding="utf-8")
        result = subprocess.run(
            [
                "uv",
                "pip",
                "compile",
                str(ROOT / "requirements.txt"),
                str(extras),
                "--python-version",
                python_version,
                "--no-header",
                "-q",
                "-o",
                str(Path(tmp) / "resolved.txt"),
            ],
            check=False,
        )
    return result.returncode


if __name__ == "__main__":
    sys.exit(main())