|
|
@@ -270,24 +270,48 @@ New-Item -ItemType Directory -Force -Path $bakSitePackages | Out-Null
|
|
|
if (Test-Path $pyEmbeddedExe) {
|
|
|
$embeddedPipOk = $false
|
|
|
$toolchainOk = $false
|
|
|
- & $pyEmbeddedExe -m pip --version 2>$null | Out-Null
|
|
|
- if ($LASTEXITCODE -eq 0) { $embeddedPipOk = $true }
|
|
|
+ $getPipScript = Join-Path $pythonRoot 'get-pip.py'
|
|
|
+ $requiredPipFiles = @(
|
|
|
+ (Join-Path $embSitePackages 'pip\__main__.py'),
|
|
|
+ (Join-Path $embSitePackages 'pip\_internal\cli\main.py'),
|
|
|
+ (Join-Path $embSitePackages 'pip\_internal\operations\build\metadata.py')
|
|
|
+ )
|
|
|
+ $requiredToolchainFiles = @(
|
|
|
+ (Join-Path $embSitePackages 'setuptools\build_meta.py'),
|
|
|
+ (Join-Path $embSitePackages 'wheel\__init__.py')
|
|
|
+ )
|
|
|
+ $pipMissing = @($requiredPipFiles | Where-Object { -not (Test-Path $_) })
|
|
|
+ if ($pipMissing.Count -eq 0) { $embeddedPipOk = $true }
|
|
|
|
|
|
if (-not $embeddedPipOk) {
|
|
|
Write-Host '[WARN] Embedded pip missing or broken; restoring from backup\site-packages (copy)...' -ForegroundColor Yellow
|
|
|
Get-ChildItem -LiteralPath $bakSitePackages -ErrorAction SilentlyContinue | ForEach-Object {
|
|
|
Copy-Item -LiteralPath $_.FullName -Destination $embSitePackages -Recurse -Force
|
|
|
}
|
|
|
- & $pyEmbeddedExe -m pip --version 2>$null | Out-Null
|
|
|
- if ($LASTEXITCODE -eq 0) {
|
|
|
+ $pipMissing = @($requiredPipFiles | Where-Object { -not (Test-Path $_) })
|
|
|
+ if ($pipMissing.Count -eq 0) {
|
|
|
$embeddedPipOk = $true
|
|
|
Write-Host '[OK] pip restored from local backup (no download)' -ForegroundColor Green
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (-not $embeddedPipOk) {
|
|
|
+ Write-Host '[WARN] pip still broken after backup copy; reinstalling pip with local get-pip.py...' -ForegroundColor Yellow
|
|
|
+ if (Test-Path $getPipScript) {
|
|
|
+ & $pyEmbeddedExe $getPipScript --force-reinstall -i $pypiIndexUrl --trusted-host $pypiTrustedHost
|
|
|
+ $pipMissing = @($requiredPipFiles | Where-Object { -not (Test-Path $_) })
|
|
|
+ if ($pipMissing.Count -eq 0) {
|
|
|
+ $embeddedPipOk = $true
|
|
|
+ Write-Host '[OK] pip repaired by get-pip.py' -ForegroundColor Green
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Write-Host ('[WARN] get-pip.py not found: ' + $getPipScript) -ForegroundColor Yellow
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if ($embeddedPipOk) {
|
|
|
- & $pyEmbeddedExe -c "import pip,setuptools,wheel; import setuptools.build_meta" 2>$null | Out-Null
|
|
|
- if ($LASTEXITCODE -eq 0) { $toolchainOk = $true }
|
|
|
+ $toolchainMissing = @($requiredToolchainFiles | Where-Object { -not (Test-Path $_) })
|
|
|
+ if ($toolchainMissing.Count -eq 0) { $toolchainOk = $true }
|
|
|
}
|
|
|
|
|
|
if (-not $toolchainOk) {
|
|
|
@@ -296,8 +320,8 @@ if (Test-Path $pyEmbeddedExe) {
|
|
|
Copy-Item -LiteralPath $_.FullName -Destination $embSitePackages -Recurse -Force
|
|
|
}
|
|
|
if ($embeddedPipOk) {
|
|
|
- & $pyEmbeddedExe -c "import pip,setuptools,wheel; import setuptools.build_meta" 2>$null | Out-Null
|
|
|
- if ($LASTEXITCODE -eq 0) {
|
|
|
+ $toolchainMissing = @($requiredToolchainFiles | Where-Object { -not (Test-Path $_) })
|
|
|
+ if ($toolchainMissing.Count -eq 0) {
|
|
|
$toolchainOk = $true
|
|
|
Write-Host '[OK] toolchain restored from backup copy' -ForegroundColor Green
|
|
|
}
|