PrOvERBs_Law / deploy_to_hf.py
Solomon7890-jpeg
Deploy ProVerBs v2.1 - App files only (logos via web upload)
6c914fc
"""
Deployment Script for ProVerBs Landing Page
Deploys to Solomon7890/ProVerbS_LaW_mAiN_PAgE
"""
import subprocess
import sys
import os
def print_banner():
print("="*60)
print("πŸš€ ProVerBs Legal AI - Landing Page Deployment")
print("="*60)
print()
def check_login():
"""Check if user is logged in to Hugging Face"""
print("πŸ” Checking Hugging Face authentication...")
try:
result = subprocess.run(['huggingface-cli', 'whoami'],
capture_output=True, text=True)
if result.returncode == 0:
username = result.stdout.strip().split('\n')[0].replace('username: ', '')
print(f" βœ… Logged in as: {username}")
return username
else:
print(" ❌ Not logged in")
return None
except Exception as e:
print(f" ❌ Error: {e}")
return None
def login_hf():
"""Login to Hugging Face"""
print("\nπŸ” Please login to Hugging Face...")
print("Token: https://huggingface.co/settings/tokens\n")
try:
subprocess.run(['huggingface-cli', 'login'])
return check_login()
except Exception as e:
print(f"❌ Login failed: {e}")
return None
def deploy_space():
"""Deploy to the Space"""
space_name = "Solomon7890/ProVerbS_LaW_mAiN_PAgE"
print(f"\nπŸ“€ Deploying to: {space_name}")
print("="*60)
try:
# Check if git is initialized
if not os.path.exists('.git'):
print("πŸ“¦ Initializing git repository...")
subprocess.run(['git', 'init'], check=True)
# Add remote if not exists
print("πŸ”— Setting up remote...")
subprocess.run(
['git', 'remote', 'add', 'space', f'https://huggingface.co/spaces/{space_name}'],
capture_output=True
)
# Set remote URL (in case it already exists)
subprocess.run(
['git', 'remote', 'set-url', 'space', f'https://huggingface.co/spaces/{space_name}'],
capture_output=True
)
# Replace app.py with enhanced version
print("πŸ“ Updating app.py with enhanced version...")
if os.path.exists('enhanced_app.py'):
import shutil
shutil.copy('enhanced_app.py', 'app.py')
print(" βœ… Enhanced app.py deployed")
# Add files
print("πŸ“‹ Adding files...")
subprocess.run(['git', 'add', 'app.py', 'README.md', '.gitattributes'], check=True)
# Commit
print("πŸ’Ύ Creating commit...")
subprocess.run(
['git', 'commit', '-m', 'Deploy enhanced ProVerBs Legal AI landing page'],
capture_output=True
)
# Push
print("πŸš€ Pushing to Hugging Face...")
result = subprocess.run(
['git', 'push', 'space', 'main', '-f'],
capture_output=True,
text=True
)
if result.returncode != 0:
# Try master branch
result = subprocess.run(
['git', 'push', 'space', 'master', '-f'],
capture_output=True,
text=True
)
if "Everything up-to-date" in result.stderr or result.returncode == 0:
print(" βœ… Deployment successful!")
return True
else:
print(" ⚠️ Push completed with warnings")
return True
except Exception as e:
print(f" ❌ Error: {e}")
return False
def main():
print_banner()
# Check login
username = check_login()
if not username:
username = login_hf()
if not username:
print("\n❌ Deployment cancelled - login required")
return
# Confirm deployment
space_url = "https://huggingface.co/spaces/Solomon7890/ProVerbS_LaW_mAiN_PAgE"
print(f"\nπŸ“‹ Deployment Target:")
print(f" Space: Solomon7890/ProVerbS_LaW_mAiN_PAgE")
print(f" URL: {space_url}")
print()
confirm = input("Deploy enhanced landing page now? (y/n): ").strip().lower()
if confirm != 'y':
print("\n❌ Deployment cancelled")
return
# Deploy
if deploy_space():
print("\n" + "="*60)
print("βœ… DEPLOYMENT SUCCESSFUL!")
print("="*60)
print()
print(f"🌐 Your Space is available at:")
print(f" {space_url}")
print()
print("⏳ The Space is now building. This may take 2-3 minutes.")
print()
print("πŸ“‹ Next steps:")
print(" 1. Visit your Space URL")
print(" 2. Wait for the build to complete")
print(" 3. Test all features")
print(" 4. Share with your audience!")
print()
print("="*60)
else:
print("\n❌ Deployment failed. Please check the errors above.")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\n❌ Deployment cancelled by user")
except Exception as e:
print(f"\n\n❌ Unexpected error: {e}")