Spaces:
Sleeping
Sleeping
Download scripts/package_space.py from msdkhairi/math2latex: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/spaces/msdkhairi/math2latex/resolve/main/scripts/package_space.py
- Command line
-
hf download hf://spaces/msdkhairi/math2latex/scripts/package_space.py
-
curl -L -o package_space.py https://huggingface.co/spaces/msdkhairi/math2latex/resolve/main/scripts/package_space.py
1.87 kB
| """Create a reviewable Gradio or Docker Space bundle locally; never uploads or writes Git.""" | |
| import argparse | |
| import shutil | |
| from pathlib import Path | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("destination", type=Path) | |
| parser.add_argument("--sdk", choices=["gradio", "docker"], default="gradio") | |
| args = parser.parse_args() | |
| source = Path(__file__).resolve().parents[1] | |
| destination = args.destination.resolve() | |
| if destination.exists(): | |
| raise SystemExit("Destination must be new to avoid overwriting files") | |
| if destination == source or source in destination.parents: | |
| raise SystemExit("Choose a destination outside this repository") | |
| destination.mkdir(parents=True) | |
| for name in ["pyproject.toml", "setup.py", "requirements.txt", "THIRD_PARTY.md"]: | |
| shutil.copy2(source / name, destination / name) | |
| for name in ["scripts", "api"]: | |
| shutil.copytree( | |
| source / name, | |
| destination / name, | |
| ignore=shutil.ignore_patterns("__pycache__", "*.pyc", "*.egg-info"), | |
| ) | |
| if args.sdk == "docker": | |
| shutil.copy2(source / "api/Dockerfile", destination / "Dockerfile") | |
| metadata = "---\ntitle: Math2LaTeX\nsdk: docker\napp_port: 7860\n---\n\nVisit /docs for an upload smoke test. See THIRD_PARTY.md.\n" | |
| (destination / "README.md").write_text(metadata) | |
| else: | |
| shutil.copy2(source / "space/app.py", destination / "app.py") | |
| shutil.copy2(source / "space/theme.css", destination / "theme.css") | |
| shutil.copytree(source / "space/examples", destination / "examples") | |
| shutil.copy2(source / "space/packages.txt", destination / "packages.txt") | |
| shutil.copy2(source / "space/README.md", destination / "README.md") | |
| print(destination) | |
| if __name__ == "__main__": | |
| main() | |