Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python3 | |
| """ | |
| Script to prepare files for Hugging Face Spaces deployment | |
| """ | |
| import os | |
| import shutil | |
| from pathlib import Path | |
| def prepare_deployment(): | |
| """Prepare files for HF Spaces deployment""" | |
| print("Preparing files for Hugging Face Spaces deployment...") | |
| # Create deployment directory | |
| deploy_dir = Path("hf_deployment") | |
| deploy_dir.mkdir(exist_ok=True) | |
| # Copy main files | |
| files_to_copy = [ | |
| ("requirements_hf.txt", "requirements.txt"), | |
| ("packages.txt", "packages.txt"), | |
| ("pre_build.py", "pre_build.py"), | |
| ("README_HF.md", "README.md"), | |
| ] | |
| for src, dst in files_to_copy: | |
| if os.path.exists(src): | |
| shutil.copy2(src, deploy_dir / dst) | |
| print(f"Copied {src} -> {dst}") | |
| else: | |
| print(f"Warning: {src} not found") | |
| # Copy demo directory | |
| if os.path.exists("demo"): | |
| shutil.copytree("demo", deploy_dir / "demo", dirs_exist_ok=True) | |
| print("Copied demo/ directory") | |
| # Copy tools directory | |
| if os.path.exists("tools"): | |
| shutil.copytree("tools", deploy_dir / "tools", dirs_exist_ok=True) | |
| print("Copied tools/ directory") | |
| # Copy other important files if they exist | |
| optional_files = ["setup.py", "LICENSE"] | |
| for file in optional_files: | |
| if os.path.exists(file): | |
| shutil.copy2(file, deploy_dir / file) | |
| print(f"Copied {file}") | |
| print(f"\nDeployment files prepared in '{deploy_dir}' directory") | |
| print("\nNext steps:") | |
| print("1. Create a new Hugging Face Space") | |
| print("2. Upload all files from the 'hf_deployment' directory") | |
| print("3. Select appropriate hardware (A10G or higher recommended)") | |
| print("4. Wait for the space to build and deploy") | |
| return deploy_dir | |
| if __name__ == "__main__": | |
| prepare_deployment() | |