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
}
$pyLauncher = Get-Command py -ErrorAction SilentlyContinue
if ($pyLauncher) {
$pythonExe = $pyLauncher.Source
$pythonArgs = @('-3')
} else {
$python = Get-Command python -ErrorAction SilentlyContinue
if ($python) {
$pythonExe = $python.Source
$pythonArgs = @()
} else {
$pythonRoot = Join-Path $env:RUNNER_TEMP 'python312'
$pythonExe = Join-Path $pythonRoot 'python.exe'
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 = @()
}
$uvExe = Join-Path $env:RUNNER_TEMP 'uv.exe'
if (-not (Test-Path $uvExe)) {
$uvUrl = 'https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-pc-windows-msvc.zip'
$uvZip = Join-Path $env:RUNNER_TEMP 'uv.zip'
$uvExtract = Join-Path $env:RUNNER_TEMP 'uv-extract'
if (Test-Path $uvExtract) { Remove-Item -Recurse -Force $uvExtract }
Write-Host "Downloading uv from $uvUrl"
Invoke-WebRequest -Uri $uvUrl -OutFile $uvZip
Expand-Archive -Path $uvZip -DestinationPath $uvExtract -Force
$uvFound = Get-ChildItem -Path $uvExtract -Recurse -Filter 'uv.exe' | Select-Object -First 1
if (-not $uvFound) { throw 'uv.exe was not found in downloaded archive.' }
Copy-Item $uvFound.FullName $uvExe -Force
}
& $pythonExe @pythonArgs -m pip install --user --upgrade aqtinstall
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
& $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 "aqt Qt installation failed, exit code: $LASTEXITCODE" }
if (-not (Test-Path $windeployqt)) { throw "Qt installation finished but windeployqt was not found: $windeployqt" }
Write-Host "Qt installed: $qtPrefix"