param(
|
[string]$Capability = ""
|
)
|
|
$ErrorActionPreference = "Stop"
|
$Root = Split-Path -Parent $PSScriptRoot
|
$PythonCandidates = @(
|
(Join-Path $env:LOCALAPPDATA "Programs/Python/Python312/python.exe"),
|
(Join-Path $env:LOCALAPPDATA "Programs/Python/Python311/python.exe"),
|
(Join-Path $env:ProgramFiles "Python312/python.exe"),
|
(Join-Path $env:ProgramFiles "Python311/python.exe")
|
)
|
$PythonExe = $PythonCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
|
|
if (-not $PythonExe) {
|
throw "Python 3.11 or 3.12 was not found. Install the 64-bit Windows version first."
|
}
|
|
$PythonVersion = & $PythonExe --version
|
Write-Host "Using $PythonVersion at $PythonExe"
|
|
if ($Capability) {
|
$CapabilityDir = Join-Path $Root "capabilities/$Capability"
|
if (-not (Test-Path $CapabilityDir)) {
|
throw "Unknown capability: $Capability"
|
}
|
$Requirements = Join-Path $CapabilityDir "requirements.txt"
|
} else {
|
$Requirements = Join-Path $Root "requirements/dev.txt"
|
}
|
|
if ($Capability) {
|
$Venv = Join-Path $Root ".venvs/$Capability"
|
} else {
|
$Venv = Join-Path $Root ".venv"
|
}
|
|
if (-not (Test-Path $Venv)) {
|
& $PythonExe -m venv $Venv
|
}
|
|
$VenvPython = Join-Path $Venv "Scripts/python.exe"
|
& $VenvPython -m pip install --upgrade pip
|
& $VenvPython -m pip install -r $Requirements
|
& $VenvPython -m pip install -e $Root
|
|
Write-Host "Environment ready: $Venv"
|