Spaces:
Build error
Build error
| #!/usr/bin/env python3 | |
| """ | |
| Setup script for Hugging Face Spaces deployment | |
| """ | |
| import os | |
| import sys | |
| import subprocess | |
| from pathlib import Path | |
| def check_requirements(): | |
| """Check if all requirements are met""" | |
| print("π Checking requirements...") | |
| # Check git | |
| try: | |
| subprocess.run(["git", "--version"], capture_output=True, check=True) | |
| print("β Git available") | |
| except (subprocess.CalledProcessError, FileNotFoundError): | |
| print("β Git not found. Please install git.") | |
| return False | |
| # Check if we're in the right directory | |
| if not Path("scripts").exists(): | |
| print("β Scripts directory not found. Please run from project root.") | |
| return False | |
| print("β All requirements met") | |
| return True | |
| def create_space_repository(): | |
| """Guide user to create HF Space repository""" | |
| print("\nπ Creating Hugging Face Space Repository") | |
| print("=" * 50) | |
| print("1. Go to https://huggingface.co/spaces") | |
| print("2. Click 'Create new Space'") | |
| print("3. Fill in the details:") | |
| print(" - Name: textilindo-ai-assistant") | |
| print(" - SDK: Docker") | |
| print(" - Hardware: GPU Basic") | |
| print(" - Visibility: Public or Private") | |
| print("4. Click 'Create Space'") | |
| print("5. Copy the repository URL (e.g., https://huggingface.co/spaces/your-username/textilindo-ai-assistant)") | |
| return input("\nπ Enter your Hugging Face Space URL: ").strip() | |
| def setup_git_remote(space_url): | |
| """Setup git remote for the space""" | |
| print(f"\nπ Setting up git remote...") | |
| try: | |
| # Remove existing remote if any | |
| subprocess.run(["git", "remote", "remove", "origin"], capture_output=True) | |
| # Add new remote | |
| subprocess.run(["git", "remote", "add", "origin", space_url], check=True) | |
| print(f"β Remote added: {space_url}") | |
| return True | |
| except subprocess.CalledProcessError as e: | |
| print(f"β Failed to add remote: {e}") | |
| return False | |
| def main(): | |
| """Main setup function""" | |
| print("π Textilindo AI Assistant - Hugging Face Spaces Setup") | |
| print("=" * 60) | |
| # Check requirements | |
| if not check_requirements(): | |
| sys.exit(1) | |
| # Guide user to create space | |
| space_url = create_space_repository() | |
| if not space_url: | |
| print("β No space URL provided. Exiting.") | |
| sys.exit(1) | |
| # Setup git remote | |
| if not setup_git_remote(space_url): | |
| sys.exit(1) | |
| print("\nβ Setup complete!") | |
| print("\nπ Next steps:") | |
| print("1. Run: python push_to_hf_space.py") | |
| print("2. Check your Hugging Face Space") | |
| print("3. Monitor the build logs") | |
| print("4. Test the application when ready") | |
| if __name__ == "__main__": | |
| main() |