Skip to content

Commit 4295276

Browse files
committed
ci(build): resolve Python via py launcher on VM217 windows lane
VM217 runner-service PATH exposes neither conan nor a bare python (setup-python is gated off for self-hosted), so python -m pip hit CommandNotFoundException. Resolve an interpreter ourselves (py -> python3 -> python) with where.exe diagnostics on miss, and fix the unquoted sysconfig.get_path(scripts) NameError.
1 parent d9a762b commit 4295276

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,26 @@ jobs:
751751
# fork-fallback windows-2022 has it too). Inherits the job-level
752752
# ExecutionPolicy-Bypass shell (see defaults above).
753753
run: |
754-
# VM217 runner-service PATH does NOT include conan: pip drops it in a
755-
# Scripts dir that is not on PATH, so "conan --version" hit
756-
# CommandNotFoundException even though Python 3.12 is present. Install
757-
# unconditionally and export the pip Scripts dir(s) via GITHUB_PATH so
758-
# this step and later steps (Detect profile / Conan install) resolve it.
759-
python -m pip install "conan>=2.0,<3.0"
760-
$scripts = & python -c "import sysconfig; print(sysconfig.get_path(scripts))"
761-
$userScripts = & python -c "import sysconfig; print(sysconfig.get_path(scripts,nt_user))"
754+
# VM217 runner-service PATH exposes neither conan nor a bare python:
755+
# setup-python is gated off for self-hosted, so resolve an interpreter
756+
# ourselves. The Windows py launcher (C:\Windows, on PATH for all
757+
# users) is the reliable entry point; fall back py -> python3 -> python
758+
# and dump where.exe diagnostics if none resolve. Then pip-install conan
759+
# and export its Scripts dir(s) via GITHUB_PATH for later steps.
760+
$py = $null
761+
foreach ($cand in @('py','python3','python')) {
762+
if (Get-Command $cand -ErrorAction SilentlyContinue) { $py = $cand; break }
763+
}
764+
if (-not $py) {
765+
Write-Host "No Python interpreter on PATH. Diagnostics:"
766+
& where.exe python 2>&1; & where.exe py 2>&1; & where.exe python3 2>&1
767+
Write-Host "PATH=$env:PATH"
768+
throw "VM217 has no Python interpreter on the runner-service PATH"
769+
}
770+
Write-Host "Using interpreter: $py"
771+
& $py -m pip install "conan>=2.0,<3.0"
772+
$scripts = & $py -c "import sysconfig; print(sysconfig.get_path('scripts'))"
773+
$userScripts = & $py -c "import sysconfig; print(sysconfig.get_path('scripts','nt_user'))"
762774
$env:PATH = "$scripts;$userScripts;$env:PATH"
763775
Add-Content -Path $env:GITHUB_PATH -Value $scripts
764776
Add-Content -Path $env:GITHUB_PATH -Value $userScripts

0 commit comments

Comments
 (0)