diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index f0458a2..b205ff8 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -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" }