Преглед изворни кода

减少了pip里面安装项目

ychael пре 2 месеци
родитељ
комит
3ddbf13b5a
2 измењених фајлова са 32 додато и 81 уклоњено
  1. 32 8
      enviroment-check.ps1
  2. 0 73
      python/x64/environment.txt

+ 32 - 8
enviroment-check.ps1

@@ -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
             }

+ 0 - 73
python/x64/environment.txt

@@ -1,96 +1,23 @@
-about-time==4.2.1
-aistudio-sdk==0.3.8
 alive-progress==3.3.0
-annotated-doc==0.0.4
-annotated-types==0.7.0
-antlr4-python3-runtime==4.9.3
-anyio==4.12.1
-bce-python-sdk==0.9.63
 beautifulsoup4==4.14.3
-certifi==2026.2.25
-cffi==2.0.0
-chardet==5.2.0
-charset-normalizer==3.4.6
 click==8.3.1
-cloudscraper==1.2.71
-colorama==0.4.6
 colorlog==6.10.1
-curl_cffi==0.14.0
 fake-useragent==2.2.0
-filelock==3.25.2
-flatbuffers==25.12.19
-fsspec==2026.2.0
-future==1.0.0
-graphemeu==0.7.2
-greenlet==3.3.2
-h11==0.16.0
-hf-xet==1.4.2
-httpcore==1.0.9
-httpx==0.28.1
-huggingface_hub==1.7.1
-humanfriendly==10.0
-idna==3.11
-imagesize==2.0.0
 json_repair==0.58.6
-lxml==6.0.2
-markdown-it-py==4.0.0
-mdurl==0.1.2
-modelscope==1.35.0
-mpmath==1.3.0
-networkx==3.6.1
 numpy==2.4.1
 omegaconf==2.3.0
 onnxruntime==1.24.3
-opencv-contrib-python==4.10.0.84
 opencv-python==4.13.0.90
-opencv-python-headless==4.13.0.90
-opt-einsum==3.3.0
-packaging==26.0
-paddlepaddle==3.2.2
-paddlex==3.4.2
-pandas==3.0.1
 pathvalidate==3.3.1
 pillow==12.1.1
 platformdirs==4.9.4
-playwright==1.58.0
 prettytable==3.17.0
 primp==1.1.3
-protobuf==7.34.0
-psutil==7.2.2
-py-cpuinfo==9.0.0
 pyclipper==1.4.0
-pycparser==3.0
-pycryptodome==3.23.0
-pydantic==2.12.5
-pydantic_core==2.41.5
-pyee==13.0.1
-pyfreeproxy==0.3.7
-Pygments==2.19.2
-pyparsing==3.3.2
-pypdfium2==5.6.0
-pyreadline3==3.5.4
 python-bidi==0.6.7
-python-dateutil==2.9.0.post0
 PyYAML==6.0.2
-quickjs==1.19.4
 requests==2.32.5
-requests-toolbelt==1.0.0
-rich==14.3.3
-ruamel.yaml==0.19.1
-safetensors==0.7.0
 setuptools==82.0.1
 shapely==2.1.2
-shellingham==1.5.4
-six==1.17.0
-soupsieve==2.8.3
-standard-imghdr==3.13.0
-sympy==1.14.0
 tqdm==4.67.3
-typer==0.24.1
-typing-inspection==0.4.2
-typing_extensions==4.15.0
-tzdata==2025.3
-ujson==5.12.0
-urllib3==2.6.3
-wcwidth==0.6.0
 wheel==0.46.3