151 lines
4.6 KiB
Python
151 lines
4.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
FLUX.1 Edit MCP Server - Dependency Check Script
|
|
This script checks if all required dependencies are properly installed
|
|
"""
|
|
|
|
import sys
|
|
import importlib.util
|
|
from typing import List, Tuple
|
|
|
|
def check_dependency(module_name: str, package_name: str = None) -> Tuple[bool, str]:
|
|
"""
|
|
Check if a dependency is installed and importable
|
|
|
|
Args:
|
|
module_name: Name of the module to import
|
|
package_name: Name of the package to install (if different from module)
|
|
|
|
Returns:
|
|
Tuple of (success, message)
|
|
"""
|
|
if package_name is None:
|
|
package_name = module_name
|
|
|
|
try:
|
|
spec = importlib.util.find_spec(module_name)
|
|
if spec is None:
|
|
return False, f"[MISSING] {module_name} not found - install with: pip install {package_name}"
|
|
|
|
# Try to actually import it
|
|
module = importlib.import_module(module_name)
|
|
|
|
# Get version if available
|
|
version = getattr(module, '__version__', 'unknown')
|
|
return True, f"[OK] {module_name} {version}"
|
|
|
|
except ImportError as e:
|
|
return False, f"[ERROR] {module_name} import failed: {e}"
|
|
except Exception as e:
|
|
return False, f"[ERROR] {module_name} error: {e}"
|
|
|
|
def check_local_modules() -> List[Tuple[bool, str]]:
|
|
"""Check local project modules"""
|
|
results = []
|
|
|
|
try:
|
|
# Add src to path temporarily
|
|
import os
|
|
from pathlib import Path
|
|
|
|
src_path = Path(__file__).parent / 'src'
|
|
if src_path.exists():
|
|
sys.path.insert(0, str(src_path))
|
|
|
|
# Test local imports
|
|
try:
|
|
from connector.config import Config
|
|
results.append((True, "[OK] Local Config module"))
|
|
except Exception as e:
|
|
results.append((False, f"[ERROR] Local Config module: {e}"))
|
|
|
|
try:
|
|
from connector.flux_client import FluxEditClient
|
|
results.append((True, "[OK] Local FluxEditClient module"))
|
|
except Exception as e:
|
|
results.append((False, f"[ERROR] Local FluxEditClient module: {e}"))
|
|
|
|
try:
|
|
from server.mcp_server import FluxEditMCPServer
|
|
results.append((True, "[OK] Local MCP Server module"))
|
|
except Exception as e:
|
|
results.append((False, f"[ERROR] Local MCP Server module: {e}"))
|
|
|
|
except Exception as e:
|
|
results.append((False, f"[ERROR] Local module check failed: {e}"))
|
|
|
|
return results
|
|
|
|
def main():
|
|
"""Main dependency check function"""
|
|
print("FLUX.1 Edit MCP Server - Dependency Check")
|
|
print("=========================================")
|
|
print(f"Python version: {sys.version}")
|
|
print(f"Python executable: {sys.executable}")
|
|
print()
|
|
|
|
# Required dependencies with their install names
|
|
dependencies = [
|
|
("aiohttp", "aiohttp==3.11.7"),
|
|
("httpx", "httpx==0.28.1"),
|
|
("mcp", "mcp==1.1.0"),
|
|
("PIL", "Pillow==11.0.0"),
|
|
("dotenv", "python-dotenv==1.0.1"),
|
|
("pydantic", "pydantic==2.10.3"),
|
|
("structlog", "structlog==24.4.0"),
|
|
]
|
|
|
|
# Optional dependencies for development
|
|
optional_dependencies = [
|
|
("pytest", "pytest==8.3.4"),
|
|
("black", "black==24.10.0"),
|
|
]
|
|
|
|
all_good = True
|
|
|
|
print("Checking required dependencies...")
|
|
print("-" * 50)
|
|
|
|
for module_name, package_name in dependencies:
|
|
success, message = check_dependency(module_name, package_name)
|
|
print(message)
|
|
if not success:
|
|
all_good = False
|
|
|
|
print()
|
|
print("Checking optional dependencies...")
|
|
print("-" * 50)
|
|
|
|
for module_name, package_name in optional_dependencies:
|
|
success, message = check_dependency(module_name, package_name)
|
|
print(message)
|
|
|
|
print()
|
|
print("Checking local modules...")
|
|
print("-" * 50)
|
|
|
|
local_results = check_local_modules()
|
|
for success, message in local_results:
|
|
print(message)
|
|
if not success:
|
|
all_good = False
|
|
|
|
print()
|
|
print("=" * 50)
|
|
|
|
if all_good:
|
|
print("[SUCCESS] All required dependencies are installed and working!")
|
|
print("You can now run: python main.py")
|
|
return 0
|
|
else:
|
|
print("[FAILED] Some dependencies are missing or broken.")
|
|
print()
|
|
print("To fix this, try:")
|
|
print("1. Run: install_dependencies.bat (Windows)")
|
|
print("2. Or run: pip install -r requirements.txt")
|
|
print("3. Or run individual pip install commands shown above")
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|