fix(setup): on Windows, only look for a system Python when the venv must be built; add uv fallback

This commit is contained in:
jamiepine
2026-10-03 09:34:44 +00:00
parent 1b8960ff77
commit d7f5ba5843
+11 -6
View File
@@ -150,6 +150,11 @@ setup-python:
& "{{ python }}" -m pip --version *> $null; \
return ($LASTEXITCODE -eq 0); \
}; \
if ((Test-Path "{{ venv }}") -and (-not (Test-Py "{{ python }}") -or -not (Test-Pip))) { \
Write-Host "Existing venv is not a working Python $target env - recreating..."; \
Remove-Item -Recurse -Force "{{ venv }}"; \
}; \
if (-not (Test-Path "{{ venv }}")) { \
$py = $null; \
if (Get-Command py -ErrorAction SilentlyContinue) { \
$p = & py "-$target" -c "import sys; print(sys.executable)" 2>$null; \
@@ -159,17 +164,17 @@ setup-python:
$c = Get-Command $n -ErrorAction SilentlyContinue; \
if ($c -and (Test-Py $c.Source)) { $py = $c.Source; break }; \
} }; \
if (-not $py -and (Get-Command uv -ErrorAction SilentlyContinue)) { \
$p = & uv python find $target 2>$null; \
if ($LASTEXITCODE -eq 0 -and (Test-Py $p)) { $py = $p }; \
}; \
if (-not $py) { \
Write-Host "ERROR: Voicebox requires Python $target (see requires-python in backend/pyproject.toml)."; \
Write-Host "Install it from https://python.org or: winget install -e --id Python.Python.$target"; \
Write-Host "Install it from https://python.org, or: winget install -e --id Python.Python.$target"; \
Write-Host " or: uv python install $target"; \
Write-Host "Then re-run: just setup"; \
exit 1; \
}; \
if ((Test-Path "{{ venv }}") -and (-not (Test-Py "{{ python }}") -or -not (Test-Pip))) { \
Write-Host "Existing venv is not a working Python $target env - recreating..."; \
Remove-Item -Recurse -Force "{{ venv }}"; \
}; \
if (-not (Test-Path "{{ venv }}")) { \
Write-Host "Creating Python virtual environment with $py ..."; \
& $py -m venv "{{ venv }}"; \
if ($LASTEXITCODE -ne 0 -or -not (Test-Pip)) { Write-Host "ERROR: could not create a working venv with $py"; exit 1 }; \