ci(lint): probe multiple Python launcher locations for SYSTEM runner
act_runner SYSTEM context may not have py.exe or python.exe in PATH. Try a list of common install paths (C:\Python3XX, Program Files, LocalAppData) and allow override via CI_PYTHON_LAUNCHER env var.
This commit is contained in:
@@ -108,8 +108,40 @@ jobs:
|
|||||||
if (Test-Path $env:VENV_DIR) {
|
if (Test-Path $env:VENV_DIR) {
|
||||||
Remove-Item $env:VENV_DIR -Recurse -Force
|
Remove-Item $env:VENV_DIR -Recurse -Force
|
||||||
}
|
}
|
||||||
$launcher = (Get-Command py.exe -ErrorAction Stop).Source
|
|
||||||
& $launcher -3.11 -m venv $env:VENV_DIR
|
# Find a usable Python launcher. act_runner runs as SYSTEM and may
|
||||||
|
# not have py.exe / python.exe in PATH; try common locations.
|
||||||
|
# Override via $env:CI_PYTHON_LAUNCHER if installed elsewhere.
|
||||||
|
$candidates = @()
|
||||||
|
if ($env:CI_PYTHON_LAUNCHER) { $candidates += $env:CI_PYTHON_LAUNCHER }
|
||||||
|
$candidates += @(
|
||||||
|
'py.exe',
|
||||||
|
'python.exe',
|
||||||
|
'C:\Python311\python.exe',
|
||||||
|
'C:\Python312\python.exe',
|
||||||
|
'C:\Python313\python.exe',
|
||||||
|
"$env:LOCALAPPDATA\Programs\Python\Python311\python.exe",
|
||||||
|
"$env:LOCALAPPDATA\Programs\Python\Python312\python.exe",
|
||||||
|
'C:\Program Files\Python311\python.exe',
|
||||||
|
'C:\Program Files\Python312\python.exe',
|
||||||
|
'C:\Program Files\Python313\python.exe'
|
||||||
|
)
|
||||||
|
$launcher = $null
|
||||||
|
foreach ($c in $candidates) {
|
||||||
|
$cmd = Get-Command $c -ErrorAction SilentlyContinue
|
||||||
|
if ($cmd) { $launcher = $cmd.Source; break }
|
||||||
|
}
|
||||||
|
if (-not $launcher) {
|
||||||
|
throw "No Python launcher found. Install Python 3.11+ system-wide or set CI_PYTHON_LAUNCHER. Tried: $($candidates -join ', ')"
|
||||||
|
}
|
||||||
|
Write-Host "Bootstrapping venv with: $launcher"
|
||||||
|
|
||||||
|
if ($launcher -like '*py.exe') {
|
||||||
|
& $launcher -3.11 -m venv $env:VENV_DIR
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
& $launcher -m venv $env:VENV_DIR
|
||||||
|
}
|
||||||
if ($LASTEXITCODE -ne 0) { throw "venv creation failed" }
|
if ($LASTEXITCODE -ne 0) { throw "venv creation failed" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user