Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Prepare the repository for Hugging Face Spaces deployment. | |
This script: | |
1. Creates a requirements.txt file with only the necessary dependencies | |
2. Ensures app.py is ready for HF deployment | |
3. Makes sure all configuration files are properly set up | |
4. Configures Hugging Face module integration if needed | |
""" | |
import os | |
import shutil | |
import sys | |
from pathlib import Path | |
# No educational module needed | |
HF_MODULE_ENABLED = False | |
def setup_hf_module(): | |
"""Setup the Hugging Face integration""" | |
print("No educational module needed - using simplified app structure.") | |
# Ensure ui directory exists for layout files | |
if not os.path.exists("ui"): | |
os.makedirs("ui") | |
print("Created ui directory") | |
def main(): | |
print("Preparing repository for Hugging Face Spaces deployment...") | |
# Make sure output directory exists | |
if not os.path.exists("output"): | |
os.makedirs("output") | |
print("Created output directory") | |
# Clean up unnecessary files | |
files_to_remove = [".env", ".env.example", ".git"] | |
for file in files_to_remove: | |
if os.path.exists(file): | |
if os.path.isdir(file): | |
shutil.rmtree(file) | |
else: | |
os.remove(file) | |
print(f"Removed {file}") | |
# Check requirements.txt exists | |
if not os.path.exists("requirements.txt"): | |
print("ERROR: requirements.txt not found. Please create it before deploying.") | |
sys.exit(1) | |
# Make sure run_local.sh is executable | |
if os.path.exists("run_local.sh"): | |
os.chmod("run_local.sh", 0o755) | |
print("Made run_local.sh executable") | |
# Configure HF module if enabled | |
setup_hf_module() | |
# Remove any large unnecessary files from input directory | |
# Keep only sample files that are needed for demos | |
print("NOTE: Large files in the input directory will be uploaded to Hugging Face.") | |
print("You may want to remove unnecessary files before deployment.") | |
print("Repository preparation complete!") | |
if __name__ == "__main__": | |
main() |