File size: 3,275 Bytes
4c75d73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
"""

Setup script for MMOP Second Try

Installs dependencies and verifies the installation

"""

import subprocess
import sys
import os
from pathlib import Path

def run_command(command, description):
    """Run a command and handle errors"""
    print(f"\n{'='*50}")
    print(f"🔧 {description}")
    print(f"{'='*50}")
    
    try:
        result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
        print(f"✅ {description} completed successfully")
        if result.stdout:
            print(f"Output: {result.stdout}")
        return True
    except subprocess.CalledProcessError as e:
        print(f"❌ {description} failed")
        print(f"Error: {e.stderr}")
        return False

def check_python_version():
    """Check if Python version is suitable"""
    print(f"🐍 Python version: {sys.version}")
    if sys.version_info < (3, 8):
        print("❌ Python 3.8 or higher is required")
        return False
    print("✅ Python version is compatible")
    return True

def install_dependencies():
    """Install dependencies from requirements.txt"""
    requirements_file = Path("requirements.txt")
    if not requirements_file.exists():
        print("❌ requirements.txt not found")
        return False
    
    return run_command(
        f"{sys.executable} -m pip install -r requirements.txt",
        "Installing dependencies"
    )

def verify_installation():
    """Verify that key components can be imported"""
    print(f"\n{'='*50}")
    print("🔍 Verifying installation")
    print(f"{'='*50}")
    
    tests = [
        ("import gradio", "Gradio UI framework"),
        ("import numpy", "NumPy"),
        ("import pandas", "Pandas"),
        ("from src.facades.game_facade import GameFacade", "Game Facade"),
        ("from src.mcp.mcp_tools import GradioMCPTools", "MCP Tools"),
        ("from app import MMORPGApplication", "Main Application"),
    ]
    
    all_passed = True
    for test_import, description in tests:
        try:
            exec(test_import)
            print(f"✅ {description}")
        except ImportError as e:
            print(f"❌ {description}: {e}")
            all_passed = False
        except Exception as e:
            print(f"⚠️  {description}: {e}")
    
    return all_passed

def main():
    """Main setup function"""
    print("🎮 MMOP Second Try - Setup Script")
    print("=" * 50)
    
    # Check Python version
    if not check_python_version():
        sys.exit(1)
    
    # Install dependencies
    if not install_dependencies():
        print("\n❌ Dependency installation failed")
        sys.exit(1)
    
    # Verify installation
    if not verify_installation():
        print("\n⚠️  Some components failed verification, but you can still try running the application")
    else:
        print("\n🎉 Setup completed successfully!")
    
    print(f"\n{'='*50}")
    print("🚀 Next steps:")
    print("1. Run the application: python app.py")
    print("2. Open your browser to the displayed URL")
    print("3. Start playing your MMORPG!")
    print(f"{'='*50}")

if __name__ == "__main__":
    main()