ychael hace 2 meses
padre
commit
3abb2b57ee

+ 2 - 2
enviroment-check.ps1

@@ -330,7 +330,7 @@ if (Test-Path $pyEmbeddedExe) {
 
     if (-not $toolchainOk -and $embeddedPipOk) {
         Write-Host '[WARN] backup copy not enough; trying backup whl offline install...' -ForegroundColor Yellow
-        & $pyEmbeddedExe -m pip install --no-index --find-links $bakRoot --upgrade pip setuptools wheel
+        & $pyEmbeddedExe -m pip install --no-index --find-links $bakRoot --upgrade pip setuptools wheel --no-warn-script-location
         & $pyEmbeddedExe -c "import pip,setuptools,wheel; import setuptools.build_meta" 2>$null | Out-Null
         if ($LASTEXITCODE -eq 0) {
             $toolchainOk = $true
@@ -340,7 +340,7 @@ if (Test-Path $pyEmbeddedExe) {
 
     if (-not $toolchainOk -and $embeddedPipOk) {
         Write-Host '[WARN] offline backup not enough; upgrading via Tsinghua mirror...' -ForegroundColor Yellow
-        & $pyEmbeddedExe -m pip install -i $pypiIndexUrl --trusted-host $pypiTrustedHost --upgrade pip setuptools wheel
+        & $pyEmbeddedExe -m pip install -i $pypiIndexUrl --trusted-host $pypiTrustedHost --upgrade pip setuptools wheel --no-warn-script-location
         & $pyEmbeddedExe -c "import pip,setuptools,wheel; import setuptools.build_meta" 2>$null | Out-Null
         if ($LASTEXITCODE -eq 0) {
             $toolchainOk = $true

+ 3 - 13
nodejs/dependences/arm64/nodejs-dependencies-install.js

@@ -164,18 +164,12 @@ while (currentMissing.length > 0 && retryCount < maxRetries) {
     let installSuccess = false;
     for (const registry of registries) {
         log(`\nTrying ${registry.name} registry...`, 'cyan');
-        execSync(`npm config set registry ${registry.url}`, { 
+        // Run npm install with output visible (registry passed per command)
+        execSync(`npm install --registry=${registry.url} --no-audit --no-fund`, {
             stdio: 'inherit',
             cwd: projectRoot
         });
         
-        // Run npm install with output visible
-        const installResult = execSync('npm install', { 
-            stdio: 'inherit',
-            cwd: projectRoot,
-            encoding: 'utf-8'
-        });
-        
         // Check if installation was successful by re-checking packages
         const installedPackagesSetAfterInstall = getInstalledPackagesFromFilesystem();
         const stillMissing = [];
@@ -198,11 +192,7 @@ while (currentMissing.length > 0 && retryCount < maxRetries) {
     if (!installSuccess) {
         // Final attempt with original registry
         log('\nTrying default npm registry...', 'cyan');
-        execSync('npm config set registry https://registry.npmjs.org/', { 
-            stdio: 'inherit',
-            cwd: projectRoot
-        });
-        execSync('npm install', { 
+        execSync('npm install --registry=https://registry.npmjs.org/ --no-audit --no-fund', {
             stdio: 'inherit',
             cwd: projectRoot
         });

+ 2 - 4
nodejs/dependences/x64/nodejs-dependencies-install.js

@@ -157,9 +157,8 @@ function main() {
     let installOk = false;
     for (const registry of registries) {
         log(`Running npm install (registry: ${registry.name})...`, 'cyan');
-        execSync(`"${npmCmd}" config set registry ${registry.url}`, { stdio: 'pipe', cwd: projectRoot, env: process.env });
         try {
-            execSync(`"${npmCmd}" install ${npmInstallPrefix} --ignore-engines --no-audit`, { stdio: 'inherit', cwd: projectRoot, env: process.env });
+            execSync(`"${npmCmd}" install ${npmInstallPrefix} --registry=${registry.url} --no-audit --no-fund`, { stdio: 'inherit', cwd: projectRoot, env: process.env });
             installOk = true;
             log(`[OK] Installed using ${registry.name}`, 'green');
             break;
@@ -169,8 +168,7 @@ function main() {
     }
     if (!installOk) {
         log('Trying default npm registry...', 'cyan');
-        execSync(`"${npmCmd}" config set registry https://registry.npmjs.org/`, { stdio: 'pipe', cwd: projectRoot, env: process.env });
-        execSync(`"${npmCmd}" install ${npmInstallPrefix} --ignore-engines --no-audit`, { stdio: 'inherit', cwd: projectRoot, env: process.env });
+        execSync(`"${npmCmd}" install ${npmInstallPrefix} --registry=https://registry.npmjs.org/ --no-audit --no-fund`, { stdio: 'inherit', cwd: projectRoot, env: process.env });
     }
 
     const installed = getInstalledPackages();

+ 20 - 20
python/arm64/python-enviroment-install.py

@@ -61,14 +61,14 @@ def repair_pip_with_get_pip():
             req = urllib.request.urlopen(GET_PIP_URL, timeout=30)
             f.write(req.read())
             get_pip_path = f.name
-        ok, _, _ = run_command(f'"{sys.executable}" "{get_pip_path}" --force-reinstall', check=False)
+        ok, _, _ = run_command(f'"{sys.executable}" "{get_pip_path}" --force-reinstall --no-warn-script-location', check=False)
         try:
             os.unlink(get_pip_path)
         except Exception:
             pass
         return ok
     except Exception as e:
-        print(f"[WARN] 下载/执行 get-pip.py 失败: {e}")
+        print(f"[WARN] Failed to download or run get-pip.py: {e}")
         return False
 
 
@@ -110,12 +110,12 @@ def ensure_venv():
         merged = (error or "") + (out or "")
         if not success and "No module named venv" in merged:
             # 方案1:重装 virtualenv 后使用
-            print("[WARN] 标准库 venv 不可用,正在重装 virtualenv...")
-            pip_ok, pip_out, pip_err = run_command(f'"{PY_PIP}" install --force-reinstall virtualenv', check=False)
+            print("[WARN] stdlib venv is unavailable, reinstalling virtualenv...")
+            pip_ok, pip_out, pip_err = run_command(f'"{PY_PIP}" install --no-warn-script-location --force-reinstall virtualenv', check=False)
             if not pip_ok:
-                print(f"[X] 重装 virtualenv 失败: {(pip_err or '') + (pip_out or '')}")
+                print(f"[X] Failed to reinstall virtualenv: {(pip_err or '') + (pip_out or '')}")
                 sys.exit(1)
-            print("[OK] virtualenv 已重装")
+            print("[OK] virtualenv reinstalled")
             venv_cmd = f'"{sys.executable}" -m virtualenv "{VENV_PATH}"'
             success, out, error = run_command(venv_cmd, check=False)
             merged = (error or "") + (out or "")
@@ -128,37 +128,37 @@ def ensure_venv():
                 if VENV_PATH.exists():
                     try:
                         shutil.rmtree(VENV_PATH)
-                        print("[OK] 已删除原虚拟环境目录,将重新创建")
+                        print("[OK] Old virtual environment removed, recreating...")
                     except Exception as e:
-                        print(f"[WARN] 删除 env 失败: {e}")
-                print("[WARN] virtualenv 异常,正在重装 virtualenv...")
+                        print(f"[WARN] Failed to remove env: {e}")
+                print("[WARN] virtualenv is broken, reinstalling virtualenv...")
                 reinstall_ok, _, reinstall_err = run_command(
-                    f'"{sys.executable}" -m pip install --force-reinstall virtualenv',
+                    f'"{sys.executable}" -m pip install --no-warn-script-location --force-reinstall virtualenv',
                     check=False
                 )
                 if not reinstall_ok and ("pip._internal" in (reinstall_err or "") or "ModuleNotFoundError" in (reinstall_err or "")):
-                    print("[WARN] pip 异常(嵌入式 pip 可能不完整),正在修复 pip...")
+                    print("[WARN] pip is broken (embedded pip may be incomplete), repairing pip...")
                     ensure_ok, _, _ = run_command(f'"{sys.executable}" -m ensurepip --upgrade', check=False)
                     if ensure_ok:
                         reinstall_ok, _, reinstall_err = run_command(
-                            f'"{sys.executable}" -m pip install --force-reinstall virtualenv',
+                            f'"{sys.executable}" -m pip install --no-warn-script-location --force-reinstall virtualenv',
                             check=False
                         )
                     if not reinstall_ok:
-                        print("[WARN] 使用官方 get-pip.py 重装 pip...")
+                        print("[WARN] Reinstalling pip with official get-pip.py...")
                         if repair_pip_with_get_pip():
                             reinstall_ok, _, reinstall_err = run_command(
-                                f'"{sys.executable}" -m pip install --force-reinstall virtualenv',
+                                f'"{sys.executable}" -m pip install --no-warn-script-location --force-reinstall virtualenv',
                                 check=False
                             )
                     if not reinstall_ok:
-                        print(f"[X] 重装 virtualenv 失败: {reinstall_err or '(no output)'}")
-                        print("[HINT] 嵌入式 python 内 pip 不完整(缺 pip._internal.operations.build)时,可手动: 下载 get-pip.py 后执行 python get-pip.py --force-reinstall")
+                        print(f"[X] Failed to reinstall virtualenv: {reinstall_err or '(no output)'}")
+                        print("[HINT] If embedded pip is incomplete (missing pip._internal.operations.build), download get-pip.py and run: python get-pip.py --force-reinstall")
                         sys.exit(1)
                 if not reinstall_ok:
-                    print(f"[X] 重装 virtualenv 失败: {reinstall_err or '(no output)'}")
+                    print(f"[X] Failed to reinstall virtualenv: {reinstall_err or '(no output)'}")
                     sys.exit(1)
-                print("[OK] virtualenv 重装完成")
+                print("[OK] virtualenv reinstall completed")
                 success, out, error = run_command(f'"{sys.executable}" -m venv "{VENV_PATH}"', check=False)
                 merged = (error or "") + (out or "")
                 if not success and "No module named venv" in merged:
@@ -265,7 +265,7 @@ def install_packages(packages, source_file, venv_pip):
     
     if source_file == REQUIREMENTS_FILE and REQUIREMENTS_FILE.exists():
         # 使用 requirements.txt 批量安装
-        cmd = f'"{venv_pip}" install -r "{source_file}"'
+        cmd = f'"{venv_pip}" install --no-warn-script-location -r "{source_file}"'
         success, _, error = run_command(cmd, check=False)
         if not success:
             print(f"[X] Installation failed: {error}")
@@ -273,7 +273,7 @@ def install_packages(packages, source_file, venv_pip):
     else:
         # 逐个安装
         for package in packages:
-            cmd = f'"{venv_pip}" install {package}'
+            cmd = f'"{venv_pip}" install --no-warn-script-location {package}'
             success, _, error = run_command(cmd, check=False)
             if not success:
                 print(f"[X] Failed to install: {package}")

+ 28 - 28
python/x64/python-enviroment-install.py

@@ -105,7 +105,7 @@ def _download_get_pip(get_pip_path):
         except Exception as e:
             last_err = e
     if last_err:
-        print(f"[WARN] 下载 get-pip.py 失败: {last_err}")
+        print(f"[WARN] Failed to download get-pip.py: {last_err}")
     return False
 
 
@@ -117,7 +117,7 @@ def repair_pip_with_get_pip():
         if not _find_or_download_get_pip(get_pip_path):
             return False
         ok, out, err = run_command(
-            f'"{sys.executable}" "{get_pip_path}" --force-reinstall -i {PIP_INDEX_URL} --trusted-host {PIP_TRUSTED_HOST}',
+            f'"{sys.executable}" "{get_pip_path}" --force-reinstall -i {PIP_INDEX_URL} --trusted-host {PIP_TRUSTED_HOST} --no-warn-script-location',
             check=False
         )
         try:
@@ -126,16 +126,16 @@ def repair_pip_with_get_pip():
             pass
         return ok
     except Exception as e:
-        print(f"[WARN] 下载/执行 get-pip.py 失败: {e}")
+        print(f"[WARN] Failed to download or run get-pip.py: {e}")
         return False
 
 
 def check_pip():
     """先检测 pip 是否已安装,未安装则退出"""
     if not PY_PIP.exists():
-        print(f"[X] 缺少 pip。请将 pip.exe 放入: {PY_SCRIPTS}")
+        print(f"[X] pip is missing. Put pip.exe in: {PY_SCRIPTS}")
         sys.exit(1)
-    print("[OK] pip 已就绪")
+    print("[OK] pip is ready")
 
 
 def _venv_home():
@@ -180,14 +180,14 @@ def ensure_venv():
                 venv_cmd = f'"{PY_VIRTUALENV}" "{VENV_PATH}"'
             else:
                 if not PY_PIP.exists():
-                    print(f"[X] 缺少: {PY_PIP} 和 {PY_VIRTUALENV},请将 pip 和 virtualenv 放入 py/Scripts/")
+                    print(f"[X] Missing: {PY_PIP} and {PY_VIRTUALENV}. Put pip and virtualenv in py/Scripts/")
                     sys.exit(1)
-                print("[WARN] 缺少 venv(无法创建虚拟环境),正在使用 pip 安装 virtualenv...")
-                pip_ok, pip_out, pip_err = run_command(f'"{PY_PIP}" install {PIP_INDEX_ARGS} virtualenv', check=False)
+                print("[WARN] venv module is missing. Installing virtualenv with pip...")
+                pip_ok, pip_out, pip_err = run_command(f'"{PY_PIP}" install {PIP_INDEX_ARGS} --no-warn-script-location virtualenv', check=False)
                 if not pip_ok:
-                    print(f"[X] 安装 virtualenv 失败,缺少: virtualenv。错误: {(pip_err or '') + (pip_out or '')}")
+                    print(f"[X] Failed to install virtualenv. Error: {(pip_err or '') + (pip_out or '')}")
                     sys.exit(1)
-                print("[OK] pip 安装 virtualenv 成功")
+                print("[OK] virtualenv installed successfully via pip")
                 venv_cmd = f'"{PY_VIRTUALENV}" "{VENV_PATH}"' if PY_VIRTUALENV.exists() else f'"{sys.executable}" -m virtualenv "{VENV_PATH}"'
             success, out, err = run_command(venv_cmd, check=False)
             merged_err = (err or "") + (out or "")
@@ -201,40 +201,40 @@ def ensure_venv():
                 if VENV_PATH.exists():
                     try:
                         shutil.rmtree(VENV_PATH)
-                        print("[OK] 已删除原虚拟环境目录,将重新创建")
+                        print("[OK] Old virtual environment removed, recreating...")
                     except Exception as e:
-                        print(f"[WARN] 删除 env 失败: {e}")
-                print("[WARN] virtualenv 异常,正在重装 virtualenv...")
+                        print(f"[WARN] Failed to remove env: {e}")
+                print("[WARN] virtualenv is broken, reinstalling virtualenv...")
                 reinstall_ok, _, reinstall_err = run_command(
-                    f'"{sys.executable}" -m pip install {PIP_INDEX_ARGS} --force-reinstall virtualenv',
+                    f'"{sys.executable}" -m pip install {PIP_INDEX_ARGS} --no-warn-script-location --force-reinstall virtualenv',
                     check=False
                 )
                 # pip 自身损坏(如缺少 pip._internal.operations.build)时用 get-pip.py 重装(不依赖残缺 pip,优先国内源)
                 if not reinstall_ok and ("pip._internal" in (reinstall_err or "") or "ModuleNotFoundError" in (reinstall_err or "")):
-                    print("[WARN] pip 异常(嵌入式 pip 可能不完整),正在用 get-pip.py 重装 pip(优先国内源)...")
+                    print("[WARN] pip is broken (embedded pip may be incomplete), reinstalling pip with get-pip.py...")
                     if repair_pip_with_get_pip():
                         reinstall_ok, _, reinstall_err = run_command(
-                            f'"{sys.executable}" -m pip install {PIP_INDEX_ARGS} --force-reinstall virtualenv',
+                            f'"{sys.executable}" -m pip install {PIP_INDEX_ARGS} --no-warn-script-location --force-reinstall virtualenv',
                             check=False
                         )
                     if not reinstall_ok:
                         ensure_ok, _, _ = run_command(f'"{sys.executable}" -m ensurepip --upgrade', check=False)
                         if ensure_ok:
                             reinstall_ok, _, reinstall_err = run_command(
-                                f'"{sys.executable}" -m pip install {PIP_INDEX_ARGS} --force-reinstall virtualenv',
+                                f'"{sys.executable}" -m pip install {PIP_INDEX_ARGS} --no-warn-script-location --force-reinstall virtualenv',
                                 check=False
                             )
                     if not reinstall_ok:
-                        print(f"[X] 重装 virtualenv 失败: {reinstall_err or '(no output)'}")
-                        print("[HINT] 嵌入式 python/x64/py 内 pip 不完整(缺 pip._internal.operations.build)。")
-                        print("  方式一:把 get-pip.py 放到 python/x64/ 或项目根目录,再重新运行本脚本(会优先用本地文件)。")
-                        print("  方式二:手动执行(国内下载 get-pip.py: http://mirrors.aliyun.com/pypi/get-pip.py ):")
+                        print(f"[X] Failed to reinstall virtualenv: {reinstall_err or '(no output)'}")
+                        print("[HINT] Embedded pip in python/x64/py may be incomplete (missing pip._internal.operations.build).")
+                        print("  Option 1: put get-pip.py in python/x64/ or project root, then rerun this script (local file is preferred).")
+                        print("  Option 2: run manually (download get-pip.py from: http://mirrors.aliyun.com/pypi/get-pip.py):")
                         print("  python get-pip.py --force-reinstall -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn")
                         sys.exit(1)
                 if not reinstall_ok:
-                    print(f"[X] 重装 virtualenv 失败: {reinstall_err or '(no output)'}")
+                    print(f"[X] Failed to reinstall virtualenv: {reinstall_err or '(no output)'}")
                     sys.exit(1)
-                print("[OK] virtualenv 重装完成")
+                print("[OK] virtualenv reinstalled")
                 # 重新创建虚拟环境:优先 -m venv,再 fallback 到 virtualenv
                 success, out, err = run_command(f'"{sys.executable}" -m venv "{VENV_PATH}"', check=False)
                 merged_err = (err or "") + (out or "")
@@ -247,9 +247,9 @@ def ensure_venv():
             err_msg = merged_err.strip() or '(no error output)'
             print(f"[X] Failed to create virtual environment: {err_msg}")
             if "No discovery plugin found" in err_msg:
-                print("[HINT] virtualenv dist-info 缺少 entry_points.txt,请检查 virtualenv-*.dist-info/")
+                print("[HINT] virtualenv dist-info is missing entry_points.txt. Check virtualenv-*.dist-info/")
             if "pythonw.exe" in err_msg or "FileNotFoundError" in err_msg:
-                print("[HINT] 需要 py/pythonw.exe,可从 python.exe 复制")
+                print("[HINT] py/pythonw.exe is required. You can copy it from python.exe.")
             sys.exit(1)
         print("[OK] Virtual environment created successfully")
     return True
@@ -347,13 +347,13 @@ def install_packages(packages, source_file, venv_pip):
     total = len(packages)
     for i, package in enumerate(packages, 1):
         pkg_display = package.split("==")[0].strip() if "==" in package else package.strip()
-        print(f"[{i}/{total}] 正在安装 {pkg_display} ...", end=" ", flush=True)
-        cmd = f'"{venv_pip}" install {PIP_INDEX_ARGS} {package}'
+        print(f"[{i}/{total}] Installing {pkg_display} ...", end=" ", flush=True)
+        cmd = f'"{venv_pip}" install {PIP_INDEX_ARGS} --no-warn-script-location {package}'
         success, _, error = run_command(cmd, check=False)
         if success:
             print("OK")
         else:
-            print("失败")
+            print("FAILED")
             failed_packages.append(package)
     if failed_packages:
         return False, failed_packages