Magnus Persson
Pin gradio[mcp,oauth] so requirements.txt resolves on the Space; add Space install check
045c645 Download scripts/check_space_install.py from magnusp/image-lab: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/magnusp/image-lab/resolve/main/scripts/check_space_install.py
- Command line
-
hf download hf://spaces/magnusp/image-lab/scripts/check_space_install.py
-
curl -L -o check_space_install.py https://huggingface.co/spaces/magnusp/image-lab/resolve/main/scripts/check_space_install.py
1.3 kB
| """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()) | |