ci(lint): detect broken venv (stale base interpreter) and rebuild
The venv at F:\CI\python\venv may exist but be broken if its pyvenv.cfg points to a deleted base interpreter (e.g. a stale actions/setup-python tool_cache). Detect this by running 'python --version' and rebuild the venv with py.exe -3.11 if it fails.
This commit is contained in:
@@ -81,15 +81,28 @@ jobs:
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Production venv lives at F:\CI\python\venv (per AGENTS.md).
|
||||
# If missing, bootstrap it via the Windows Python launcher (py -3.11),
|
||||
# since the act_runner SYSTEM service does NOT have plain "python" in PATH.
|
||||
# If missing or broken (pyvenv.cfg points to a deleted base interpreter,
|
||||
# e.g. a stale actions/setup-python tool_cache), rebuild it via the
|
||||
# Windows Python launcher (py -3.11). The act_runner SYSTEM service
|
||||
# does NOT have plain "python" in PATH, but py.exe is installed system-wide.
|
||||
$venvPy = Join-Path $env:VENV_DIR 'Scripts\python.exe'
|
||||
if (-not (Test-Path $venvPy)) {
|
||||
Write-Host "Venv missing, bootstrapping at $env:VENV_DIR"
|
||||
|
||||
$venvOk = $false
|
||||
if (Test-Path $venvPy) {
|
||||
& $venvPy --version 2>&1 | Out-Null
|
||||
if ($LASTEXITCODE -eq 0) { $venvOk = $true }
|
||||
}
|
||||
|
||||
if (-not $venvOk) {
|
||||
Write-Host "Venv missing or broken, (re)bootstrapping at $env:VENV_DIR"
|
||||
if (Test-Path $env:VENV_DIR) {
|
||||
Remove-Item $env:VENV_DIR -Recurse -Force
|
||||
}
|
||||
$launcher = (Get-Command py.exe -ErrorAction Stop).Source
|
||||
& $launcher -3.11 -m venv $env:VENV_DIR
|
||||
if ($LASTEXITCODE -ne 0) { throw "venv creation failed" }
|
||||
}
|
||||
|
||||
Write-Host "Using venv python: $venvPy"
|
||||
& $venvPy --version
|
||||
if ($LASTEXITCODE -ne 0) { throw "python --version failed" }
|
||||
|
||||
Reference in New Issue
Block a user