fix: improve wheel download script reliability
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
param(
|
||||
[switch]$NoPause
|
||||
[switch]$NoPause,
|
||||
[string]$IndexUrl = "https://pypi.org/simple"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -23,6 +24,27 @@ function Get-PythonCommand {
|
||||
throw "Python was not found. Install Python 3.10+ before downloading wheels."
|
||||
}
|
||||
|
||||
function Invoke-PipDownload {
|
||||
param(
|
||||
[string]$PythonCommand,
|
||||
[string[]]$PythonArgs
|
||||
)
|
||||
|
||||
$pipArgs = @(
|
||||
"-m", "pip", "download",
|
||||
"--index-url", $IndexUrl,
|
||||
"--trusted-host", "pypi.org",
|
||||
"--trusted-host", "files.pythonhosted.org",
|
||||
"--disable-pip-version-check",
|
||||
"--retries", "3",
|
||||
"--timeout", "60",
|
||||
"-r", $Req,
|
||||
"-d", $WheelDir
|
||||
)
|
||||
|
||||
& $PythonCommand @PythonArgs @pipArgs
|
||||
}
|
||||
|
||||
try {
|
||||
Set-Location $Root
|
||||
if (-not (Test-Path $Req)) {
|
||||
@@ -34,13 +56,13 @@ try {
|
||||
|
||||
Write-Host "Downloading offline wheels to: $WheelDir" -ForegroundColor Cyan
|
||||
if ($python -eq "py") {
|
||||
& py -3 -m pip download -r $Req -d $WheelDir
|
||||
Invoke-PipDownload -PythonCommand "py" -PythonArgs @("-3")
|
||||
} else {
|
||||
& $python -m pip download -r $Req -d $WheelDir
|
||||
Invoke-PipDownload -PythonCommand $python -PythonArgs @()
|
||||
}
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Wheel download failed. Check network access and pip."
|
||||
throw "Wheel download failed. Check network access to $IndexUrl. If your environment uses a private PyPI mirror, pass -IndexUrl with the mirror address."
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
Reference in New Issue
Block a user