ci: use uv to run Qt installer on Windows
Some checks failed
Build Windows Release / Build Windows x64 Release (MSVC + Qt) (push) Failing after 1m41s

This commit is contained in:
luochen570
2026-05-30 22:05:22 +08:00
parent 1701f36942
commit 03b873d4dd

View File

@@ -61,36 +61,21 @@ jobs:
exit 0 exit 0
} }
$pyLauncher = Get-Command py -ErrorAction SilentlyContinue $uvExe = Join-Path $env:RUNNER_TEMP 'uv.exe'
if ($pyLauncher) { if (-not (Test-Path $uvExe)) {
$pythonExe = $pyLauncher.Source $uvUrl = 'https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-pc-windows-msvc.zip'
$pythonArgs = @('-3') $uvZip = Join-Path $env:RUNNER_TEMP 'uv.zip'
} else { $uvExtract = Join-Path $env:RUNNER_TEMP 'uv-extract'
$python = Get-Command python -ErrorAction SilentlyContinue if (Test-Path $uvExtract) { Remove-Item -Recurse -Force $uvExtract }
if ($python) { Write-Host "Downloading uv from $uvUrl"
$pythonExe = $python.Source Invoke-WebRequest -Uri $uvUrl -OutFile $uvZip
$pythonArgs = @() Expand-Archive -Path $uvZip -DestinationPath $uvExtract -Force
} else { $uvFound = Get-ChildItem -Path $uvExtract -Recurse -Filter 'uv.exe' | Select-Object -First 1
$pythonRoot = Join-Path $env:RUNNER_TEMP 'python312' if (-not $uvFound) { throw 'uv.exe was not found in downloaded archive.' }
$pythonExe = Join-Path $pythonRoot 'python.exe' Copy-Item $uvFound.FullName $uvExe -Force
if (-not (Test-Path $pythonExe)) {
$installer = Join-Path $env:RUNNER_TEMP 'python-installer.exe'
$pythonUrl = 'https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe'
Write-Host "Downloading Python from $pythonUrl"
Invoke-WebRequest -Uri $pythonUrl -OutFile $installer
$installArgs = @('/quiet', 'InstallAllUsers=0', "TargetDir=$pythonRoot", 'Include_pip=1', 'Include_test=0', 'PrependPath=0')
$proc = Start-Process -FilePath $installer -ArgumentList $installArgs -Wait -PassThru
if ($proc.ExitCode -ne 0) { throw "Python installer failed, exit code: $($proc.ExitCode)" }
}
if (-not (Test-Path $pythonExe)) { throw "Python installation finished but python.exe was not found: $pythonExe" }
$pythonArgs = @()
}
} }
& $pythonExe @pythonArgs -m pip install --user --upgrade aqtinstall & $uvExe tool run --from aqtinstall aqt install-qt windows desktop $env:QT_VERSION $env:QT_ARCH -O $qtRoot -m qtimageformats
if ($LASTEXITCODE -ne 0) { throw "pip install aqtinstall failed, exit code: $LASTEXITCODE" }
& $pythonExe @pythonArgs -m aqt install-qt windows desktop $env:QT_VERSION $env:QT_ARCH -O $qtRoot -m qtimageformats
if ($LASTEXITCODE -ne 0) { throw "aqt Qt installation failed, exit code: $LASTEXITCODE" } if ($LASTEXITCODE -ne 0) { throw "aqt Qt installation failed, exit code: $LASTEXITCODE" }
if (-not (Test-Path $windeployqt)) { throw "Qt installation finished but windeployqt was not found: $windeployqt" } if (-not (Test-Path $windeployqt)) { throw "Qt installation finished but windeployqt was not found: $windeployqt" }
Write-Host "Qt installed: $qtPrefix" Write-Host "Qt installed: $qtPrefix"