CI(windows): install Python to explicit TargetDir + log exit code
Per-user install landed somewhere my candidate-path check missed. Force the install dir (LOCALAPPDATA\Python312) so python.exe is found deterministically. (Linux/mac/arm64 builds succeeded; they only failed re-uploading to an existing release -- softprops' asset-delete 404s on Gitea. A fresh release avoids that.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yT89n4zR4qbrySoSiEyZs
This commit is contained in:
@@ -18,17 +18,17 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
|
||||||
Write-Host "Python not found; installing 3.12 (per-user, no admin needed)..."
|
Write-Host "Python not found; installing 3.12 to a fixed dir (no admin needed)..."
|
||||||
$url = "https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe"
|
$url = "https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe"
|
||||||
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\py.exe"
|
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\py.exe"
|
||||||
Start-Process -Wait -FilePath "$env:TEMP\py.exe" -ArgumentList "/quiet","PrependPath=1","Include_test=0"
|
$dir = "$env:LOCALAPPDATA\Python312"
|
||||||
$base = @(
|
$p = Start-Process -Wait -PassThru -FilePath "$env:TEMP\py.exe" `
|
||||||
"$env:LOCALAPPDATA\Programs\Python\Python312",
|
-ArgumentList "/quiet","TargetDir=$dir","PrependPath=1","Include_test=0"
|
||||||
"C:\Program Files\Python312",
|
Write-Host "installer exit code: $($p.ExitCode)"
|
||||||
"C:\Python312"
|
if (-not (Test-Path "$dir\python.exe")) {
|
||||||
) | Where-Object { Test-Path "$_\python.exe" } | Select-Object -First 1
|
throw "python.exe not found at $dir after install (exit $($p.ExitCode))"
|
||||||
if (-not $base) { throw "Python install did not produce python.exe in a known location" }
|
}
|
||||||
$env:Path = "$base;$base\Scripts;$env:Path"
|
$env:Path = "$dir;$dir\Scripts;$env:Path"
|
||||||
}
|
}
|
||||||
python --version
|
python --version
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
|||||||
Reference in New Issue
Block a user