43 lines
1.3 KiB
PowerShell
43 lines
1.3 KiB
PowerShell
# PowerShell script to ensure virtual environment exists, install dependencies, and run alpha.py
|
|
|
|
# Get the script directory
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
Set-Location $scriptDir
|
|
|
|
# Path to virtual environment activation script
|
|
$venvActivate = ".venv\Scripts\Activate.ps1"
|
|
|
|
# Function to create virtual environment and install dependencies
|
|
function Setup-Venv {
|
|
Write-Host "Creating virtual environment..." -ForegroundColor Green
|
|
python -m venv .venv
|
|
|
|
if (-Not (Test-Path $venvActivate)) {
|
|
Write-Host "Error: Failed to create virtual environment." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Activating virtual environment..." -ForegroundColor Green
|
|
& $venvActivate
|
|
|
|
if (Test-Path "requirements.txt") {
|
|
Write-Host "Installing dependencies from requirements.txt..." -ForegroundColor Green
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
} else {
|
|
Write-Host "No requirements.txt found, skipping dependency installation." -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
# Check if virtual environment exists
|
|
if (Test-Path $venvActivate) {
|
|
Write-Host "Activating virtual environment..." -ForegroundColor Green
|
|
& $venvActivate
|
|
} else {
|
|
Setup-Venv
|
|
}
|
|
|
|
# Run the application
|
|
Write-Host "Running alpha.py..." -ForegroundColor Green
|
|
python alpha.py
|