2026-07-02 15:30:18 +08:00
|
|
|
param(
|
|
|
|
|
[switch]$NoPause
|
|
|
|
|
)
|
|
|
|
|
|
2026-06-30 14:29:02 +08:00
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
$Root = Split-Path -Parent $PSScriptRoot
|
|
|
|
|
$WheelDir = Join-Path $Root "vendor\wheels"
|
|
|
|
|
$Req = Join-Path $Root "requirements.txt"
|
2026-07-02 15:30:18 +08:00
|
|
|
|
|
|
|
|
function Wait-BeforeExit {
|
|
|
|
|
if (-not $NoPause) {
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Read-Host "Press Enter to exit"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-PythonCommand {
|
|
|
|
|
foreach ($name in @("py", "python", "python3")) {
|
|
|
|
|
if (Get-Command $name -ErrorAction SilentlyContinue) {
|
|
|
|
|
return $name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw "Python was not found. Install Python 3.10+ before downloading wheels."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Set-Location $Root
|
|
|
|
|
if (-not (Test-Path $Req)) {
|
|
|
|
|
throw "requirements.txt was not found: $Req"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$python = Get-PythonCommand
|
|
|
|
|
New-Item -ItemType Directory -Force -Path $WheelDir | Out-Null
|
|
|
|
|
|
|
|
|
|
Write-Host "Downloading offline wheels to: $WheelDir" -ForegroundColor Cyan
|
|
|
|
|
if ($python -eq "py") {
|
|
|
|
|
& py -3 -m pip download -r $Req -d $WheelDir
|
|
|
|
|
} else {
|
|
|
|
|
& $python -m pip download -r $Req -d $WheelDir
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
|
throw "Wheel download failed. Check network access and pip."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host "Offline wheels downloaded. Copy the whole project folder to the server and run scripts\install_offline.ps1." -ForegroundColor Green
|
|
|
|
|
} catch {
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host "Download failed:" -ForegroundColor Red
|
|
|
|
|
Write-Host $_.Exception.Message -ForegroundColor Red
|
|
|
|
|
exit 1
|
|
|
|
|
} finally {
|
|
|
|
|
Wait-BeforeExit
|
|
|
|
|
}
|