From b262b1e664ef742186b825f34ae2552e1f52603a Mon Sep 17 00:00:00 2001 From: TheMajesticMagician Date: Sun, 25 Oct 2026 17:06:10 -0600 Subject: [PATCH] Fix Python 3.11 detection in the Windows build script sys.version_info[:2] prints '(3, 11)', so the old substring check for '3.11' always failed even on a valid Python install. Probe the major.minor string explicitly and support the py launcher or python on PATH. Co-Authored-By: Claude Code --- build_windows.ps1 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/build_windows.ps1 b/build_windows.ps1 index 035e9f6..08cfdf9 100644 --- a/build_windows.ps1 +++ b/build_windows.ps1 @@ -10,15 +10,19 @@ $Root = Split-Path -Parent $MyInvocation.MyCommand.Path Set-Location $Root function Get-Python { - $candidates = @("py -3.11", "py -3", "python") + $candidates = @( + @{ Command = "py"; Arguments = @("-3.11") }, + @{ Command = "py"; Arguments = @("-3") }, + @{ Command = "python"; Arguments = @() }, + @{ Command = "python3"; Arguments = @() } + ) foreach ($candidate in $candidates) { try { - $parts = $candidate.Split(" ") - $exe = $parts[0] - $exeArgs = @($parts | Select-Object -Skip 1) - $output = & $exe @exeArgs -c "import sys; print(sys.executable); print(sys.version_info[:2])" 2>$null - if ($LASTEXITCODE -eq 0 -and $output -match "3\.11") { - return $parts + $exe = $candidate.Command + $exeArgs = @($candidate.Arguments) + $probe = & $exe @exeArgs -c "import sys; print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))" 2>$null + if ($LASTEXITCODE -eq 0 -and (($probe | Out-String).Trim() -eq "3.11")) { + return $candidate } } catch { } } @@ -31,8 +35,8 @@ $python = Get-Python if (-not (Test-Path $venv)) { Write-Host "Creating build environment..." - $pythonExe = $python[0] - $pythonArgs = @($python | Select-Object -Skip 1) + $pythonExe = $python.Command + $pythonArgs = @($python.Arguments) & $pythonExe @pythonArgs -m venv $venv } $py = Join-Path $venv "Scripts\python.exe"