139 lines
5.2 KiB
PowerShell
139 lines
5.2 KiB
PowerShell
# PowerShell script to install FLUX.1 Edit MCP Server Dependencies
|
|
|
|
Write-Host "Installing FLUX.1 Edit MCP Server Dependencies..." -ForegroundColor Green
|
|
Write-Host "===============================================" -ForegroundColor Green
|
|
|
|
# Check if Python is available
|
|
try {
|
|
$pythonVersion = python --version
|
|
Write-Host "Found Python: $pythonVersion" -ForegroundColor Blue
|
|
} catch {
|
|
Write-Host "Error: Python is not installed or not in PATH" -ForegroundColor Red
|
|
Write-Host "Please install Python 3.8 or higher from https://python.org" -ForegroundColor Yellow
|
|
Read-Host "Press Enter to exit"
|
|
exit 1
|
|
}
|
|
|
|
# Check if pip is available
|
|
try {
|
|
$pipVersion = pip --version
|
|
Write-Host "Found pip: $pipVersion" -ForegroundColor Blue
|
|
} catch {
|
|
Write-Host "Error: pip is not available" -ForegroundColor Red
|
|
Write-Host "Please ensure pip is installed with Python" -ForegroundColor Yellow
|
|
Read-Host "Press Enter to exit"
|
|
exit 1
|
|
}
|
|
|
|
# Update pip to latest version
|
|
Write-Host "Updating pip..." -ForegroundColor Blue
|
|
try {
|
|
python -m pip install --upgrade pip
|
|
Write-Host "pip updated successfully" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "Warning: Failed to upgrade pip, continuing with current version" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Check if virtual environment exists, create if not
|
|
if (-not (Test-Path "venv")) {
|
|
Write-Host "Creating virtual environment..." -ForegroundColor Yellow
|
|
python -m venv venv
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Error: Failed to create virtual environment" -ForegroundColor Red
|
|
Write-Host "This might be due to permissions or Python installation issues" -ForegroundColor Yellow
|
|
Read-Host "Press Enter to exit"
|
|
exit 1
|
|
}
|
|
Write-Host "Virtual environment created successfully." -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Virtual environment already exists." -ForegroundColor Blue
|
|
}
|
|
|
|
# Activate virtual environment
|
|
Write-Host "Activating virtual environment..." -ForegroundColor Blue
|
|
try {
|
|
& "venv\Scripts\Activate.ps1"
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Activation failed"
|
|
}
|
|
Write-Host "Virtual environment activated." -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "Error: Failed to activate virtual environment" -ForegroundColor Red
|
|
Write-Host "Trying to recreate virtual environment..." -ForegroundColor Yellow
|
|
Remove-Item -Recurse -Force "venv" -ErrorAction SilentlyContinue
|
|
python -m venv venv
|
|
& "venv\Scripts\Activate.ps1"
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Error: Still failed to activate virtual environment" -ForegroundColor Red
|
|
Write-Host "You might need to enable PowerShell script execution:" -ForegroundColor Yellow
|
|
Write-Host "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser" -ForegroundColor Yellow
|
|
Read-Host "Press Enter to exit"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
Write-Host "Current Python location:" -ForegroundColor Blue
|
|
& where.exe python
|
|
|
|
# Install dependencies with explicit error handling
|
|
Write-Host "`nInstalling dependencies from requirements.txt..." -ForegroundColor Blue
|
|
try {
|
|
pip install -r requirements.txt --no-cache-dir -v
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "pip install failed"
|
|
}
|
|
Write-Host "Dependencies installed successfully!" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "Error: Failed to install some dependencies" -ForegroundColor Red
|
|
Write-Host "Trying to install critical dependencies individually..." -ForegroundColor Yellow
|
|
|
|
$criticalPackages = @(
|
|
"aiohttp==3.11.7",
|
|
"httpx==0.28.1",
|
|
"mcp==1.1.0",
|
|
"Pillow==11.0.0",
|
|
"python-dotenv==1.0.1",
|
|
"pydantic==2.10.3",
|
|
"structlog==24.4.0"
|
|
)
|
|
|
|
foreach ($package in $criticalPackages) {
|
|
Write-Host "Installing $package..." -ForegroundColor Blue
|
|
pip install $package
|
|
}
|
|
}
|
|
|
|
# Verify installations
|
|
Write-Host "`nVerifying installations..." -ForegroundColor Blue
|
|
try {
|
|
$aiohttpVersion = python -c "import aiohttp; print(f'aiohttp version: {aiohttp.__version__}')" 2>$null
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host $aiohttpVersion -ForegroundColor Green
|
|
} else {
|
|
throw "aiohttp import failed"
|
|
}
|
|
} catch {
|
|
Write-Host "Error: aiohttp is not properly installed" -ForegroundColor Red
|
|
Write-Host "Trying alternative installation method..." -ForegroundColor Yellow
|
|
pip install --force-reinstall aiohttp
|
|
}
|
|
|
|
try {
|
|
python -c "import mcp; print('mcp module imported successfully')" 2>$null
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "mcp module imported successfully" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Warning: mcp module check failed, but this might be normal" -ForegroundColor Yellow
|
|
}
|
|
} catch {
|
|
Write-Host "Warning: mcp module verification failed" -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host "`nInstallation completed!" -ForegroundColor Green
|
|
Write-Host "`nNext steps:" -ForegroundColor Yellow
|
|
Write-Host "1. Copy .env.example to .env: Copy-Item .env.example .env" -ForegroundColor White
|
|
Write-Host "2. Edit .env file and add your FLUX_API_KEY" -ForegroundColor White
|
|
Write-Host "3. Run the server with: .\run.ps1 or python main.py" -ForegroundColor White
|
|
Write-Host ""
|
|
Read-Host "Press Enter to exit"
|