atropos/environments/dynastai/setup.py
Earl Potters 7101aad190 Add DynastAI integration documentation and setup scripts
- Introduced `ATROPOS_INTEGRATION.md` for detailed instructions on using DynastAI with Atropos.
- Added `INSTALL_AND_RUN.md` to guide users through installation and running the game.
- Created `run_dynastai.py` for a simplified testing experience without full Atropos setup.
- Implemented `setup.py` to manage dependencies and ensure compatibility.
- Updated `requirements.txt` to include additional dependencies and version constraints.
- Enhanced `README.md` with new sections on installation, running the game, and integration with Atropos.
- Added installation verification script `verify_install.py` to check for required packages.
- Updated game logic to support local card generation and improved API integration.
- Enhanced web interface with new features for user interaction and game metrics display.
2025-05-18 21:59:12 +00:00

94 lines
3.5 KiB
Python
Executable file

#!/usr/bin/env python3
"""
DynastAI Setup Script
This script ensures that all dependencies for DynastAI are properly installed
and compatible with your Python version.
"""
import sys
import subprocess
import os
import platform
def main():
"""Run the setup process"""
print("DynastAI Setup")
print("=============")
# Check Python version
python_version = tuple(map(int, platform.python_version_tuple()))
print(f"Python version: {platform.python_version()}")
if python_version < (3, 8):
print("Error: Python 3.8 or higher is required")
sys.exit(1)
# Check built-in uuid module
print("Checking UUID module...")
try:
import uuid
print(f"UUID module version: {uuid.__version__ if hasattr(uuid, '__version__') else 'built-in'}")
except ImportError:
print("Warning: UUID module not found. This is unexpected as it should be built into Python.")
# Get script directory
script_dir = os.path.dirname(os.path.abspath(__file__))
requirements_file = os.path.join(script_dir, "requirements.txt")
# Ensure pip is up-to-date
print("\nUpdating pip...")
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
# Install dependencies with special handling
print("\nInstalling dependencies...")
# First, install key packages that others might depend on
print("Installing core dependencies...")
subprocess.run([
sys.executable, "-m", "pip", "install",
"wheel", "setuptools>=68.0.0", "typing-extensions>=4.9.0"
])
# For Python 3.13+, special handling for aiohttp
if python_version >= (3, 13):
print("\nDetected Python 3.13+, installing compatible versions of packages...")
try:
# For Python 3.13, use the newest compatible version or install from source if needed
subprocess.run([
sys.executable, "-m", "pip", "install",
"--force-reinstall", "--no-binary", "aiohttp", "aiohttp>=3.9.0"
])
print("Successfully installed aiohttp from source.")
except Exception as e:
print(f"Warning: Failed to install aiohttp from source: {e}")
print("Continuing with installation, but some features might not work.")
# Install main requirements
print("\nInstalling main requirements...")
result = subprocess.run([
sys.executable, "-m", "pip", "install", "-r", requirements_file
])
if result.returncode != 0:
print("\nTrying an alternative installation method for problematic packages...")
# Read requirements file
with open(requirements_file, 'r') as f:
requirements = [line.strip() for line in f if line.strip() and not line.startswith('#')]
# Install packages one by one
for req in requirements:
print(f"Installing {req}...")
try:
subprocess.run([sys.executable, "-m", "pip", "install", req], check=True)
except subprocess.CalledProcessError:
pkg_name = req.split('>=')[0] if '>=' in req else req.split('==')[0] if '==' in req else req
print(f"Warning: Failed to install {pkg_name}, trying without version constraint...")
subprocess.run([sys.executable, "-m", "pip", "install", pkg_name])
print("\nSetup complete! You can now run DynastAI.")
print("To start the game with web interface, run: python run_dynastai.py")
if __name__ == "__main__":
main()