Fix Windows python3 availability in container build paths.

Preserve container PATH during Windows docker-run steps and create/verify a python3 alias from Scoop Python so Quarto/Jupyter kernels that invoke python3 work reliably in both install-time and final verification checks.
This commit is contained in:
Vijay Janapa Reddi
2026-03-05 07:42:29 -05:00
parent 9ff63264cf
commit 9314128cf7
3 changed files with 48 additions and 3 deletions

View File

@@ -513,6 +513,19 @@ jobs:
}
Write-Output "📊 Python version: $pythonVersion"
$pyExe = (python -c "import sys; print(sys.executable)").Trim()
$pyDir = Split-Path $pyExe -Parent
$py3Exe = Join-Path $pyDir "python3.exe"
if (-not (Test-Path $py3Exe)) {
Copy-Item $pyExe $py3Exe -Force
}
$python3Version = python3 --version
if ($LASTEXITCODE -ne 0) {
Write-Error "❌ python3 --version failed with exit code $LASTEXITCODE"
exit 1
}
Write-Output "📊 Python3 version: $python3Version"
# Verify we got Python 3.13
if ($pythonVersion -notmatch "3\.13") {
Write-Error "❌ Expected Python 3.13, got: $pythonVersion"
@@ -1175,6 +1188,19 @@ jobs:
Write-Output " $out"
Write-Output "✅ Python verified"
- name: ✅ Verify Python3 (Windows)
if: matrix.enabled && runner.os == 'Windows'
shell: pwsh
run: |
$cmd = Get-Command python3 -ErrorAction SilentlyContinue
if (-not $cmd) { Write-Error "❌ Python3 not found"; exit 1 }
Write-Output "Resolved: $($cmd.Source)"
$out = & python3 --version 2>&1 | Select-Object -First 1
$exitCode = if ($null -eq $LASTEXITCODE) { if ($?) { 0 } else { 1 } } else { [int]$LASTEXITCODE }
if ($exitCode -ne 0) { Write-Error "❌ Python3 check failed (exit $exitCode)"; exit 1 }
Write-Output " $out"
Write-Output "✅ Python3 verified"
- name: ✅ Verify R (Windows)
if: matrix.enabled && runner.os == 'Windows'
shell: pwsh

View File

@@ -392,7 +392,6 @@ jobs:
run: |
Write-Host "🔨 Building ${{ matrix.format_name }} on Windows container..."
docker run --rm -v "$($PWD.Path):C:\workspace" -w "C:\workspace\book\quarto" ${{ env.CONTAINER_IMAGE }} pwsh -NoLogo -Command "
`$env:PATH = [Environment]::GetEnvironmentVariable('PATH','Machine')
if (Test-Path '_quarto.yml') { Remove-Item '_quarto.yml' -Force }
Copy-Item 'config\${{ matrix.config }}' '_quarto.yml' -Force
quarto render --to ${{ matrix.render_target }} --output-dir '${{ matrix.output_dir }}'
@@ -440,7 +439,6 @@ jobs:
run: |
Write-Host "🔨 Compressing PDF on Windows container..."
docker run --rm -v "$($PWD.Path):C:\workspace" -w "C:\workspace\book\quarto\${{ matrix.output_dir }}" ${{ env.CONTAINER_IMAGE }} pwsh -NoLogo -Command "
`$env:PATH = [Environment]::GetEnvironmentVariable('PATH','Machine')
if (Test-Path 'Machine-Learning-Systems.pdf') {
Write-Host '📉 Compressing PDF with professional compression tool...'
Write-Host '🔍 DEBUG: Current directory:'
@@ -516,7 +514,6 @@ jobs:
run: |
Write-Host "🔨 Compressing EPUB on Windows container..."
docker run --rm -v "$($PWD.Path):C:\workspace" -w "C:\workspace\book\quarto\${{ matrix.output_dir }}" ${{ env.CONTAINER_IMAGE }} pwsh -NoLogo -Command "
`$env:PATH = [Environment]::GetEnvironmentVariable('PATH','Machine')
if (Test-Path 'Machine-Learning-Systems.epub') {
Write-Host '📚 Compressing EPUB with optimized compression tool...'
Write-Host '🔍 DEBUG: Current directory:'

View File

@@ -227,7 +227,19 @@ RUN Write-Host '=== STARTING PYTHON INSTALLATION ===' ; `
Write-Host "❌ Python install failed: version check exited $LASTEXITCODE" ; `
exit 1 ; `
} ; `
$pyExe = (python -c "import sys; print(sys.executable)").Trim() ; `
$pyDir = Split-Path $pyExe -Parent ; `
$py3Exe = Join-Path $pyDir 'python3.exe' ; `
if (-not (Test-Path $py3Exe)) { `
Copy-Item $pyExe $py3Exe -Force ; `
} ; `
$pv3 = python3 --version ; `
if ($LASTEXITCODE -ne 0) { `
Write-Host "❌ Python install failed: python3 alias check exited $LASTEXITCODE" ; `
exit 1 ; `
} ; `
Write-Host "📦 Python installed: $pv" ; `
Write-Host "📦 Python3 alias verified: $pv3" ; `
Write-Host '✅ Python installation complete'
# ------------------------------------------------------------
@@ -382,6 +394,16 @@ RUN Write-Host '=== VERIFY: Python ===' ; `
Write-Host " $out" ; `
Write-Host '✅ Python verified'
RUN Write-Host '=== VERIFY: Python3 ===' ; `
$cmd = Get-Command python3 -ErrorAction SilentlyContinue ; `
if (-not $cmd) { Write-Host "❌ Python3 FAILED: command not found"; exit 1 } ; `
Write-Host "Resolved: $($cmd.Source)" ; `
$out = & python3 --version 2>&1 | Select-Object -First 1 ; `
$exitCode = if ($null -eq $LASTEXITCODE) { if ($?) { 0 } else { 1 } } else { [int]$LASTEXITCODE } ; `
if ($exitCode -ne 0) { Write-Host "❌ Python3 FAILED: exited $exitCode"; exit 1 } ; `
Write-Host " $out" ; `
Write-Host '✅ Python3 verified'
RUN Write-Host '=== VERIFY: R ===' ; `
$cmd = Get-Command Rscript -ErrorAction SilentlyContinue ; `
if (-not $cmd) { Write-Host "❌ R FAILED: command not found"; exit 1 } ; `