CCL_QMS检验
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.8 KiB

  1. @echo off
  2. chcp 65001 >nul
  3. setlocal EnableDelayedExpansion
  4. set "PY_EXE="
  5. set "PY_ARGS="
  6. set "PIP_INSTALL_ARGS=--disable-pip-version-check --default-timeout 180 --retries 10 --trusted-host pypi.org --trusted-host files.pythonhosted.org --trusted-host pypi.tuna.tsinghua.edu.cn --trusted-host mirrors.aliyun.com"
  7. where py >nul 2>nul
  8. if not errorlevel 1 (
  9. py -3 -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul
  10. if not errorlevel 1 (
  11. set "PY_EXE=py"
  12. set "PY_ARGS=-3"
  13. )
  14. )
  15. if not defined PY_EXE (
  16. where python3 >nul 2>nul
  17. if not errorlevel 1 (
  18. python3 -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul
  19. if not errorlevel 1 (
  20. set "PY_EXE=python3"
  21. set "PY_ARGS="
  22. )
  23. )
  24. )
  25. if not defined PY_EXE (
  26. python -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul
  27. if not errorlevel 1 (
  28. set "PY_EXE=python"
  29. set "PY_ARGS="
  30. )
  31. )
  32. if not defined PY_EXE (
  33. for %%D in ("%LocalAppData%\Programs\Python\Python312\python.exe" "%LocalAppData%\Programs\Python\Python311\python.exe" "%LocalAppData%\Programs\Python\Python310\python.exe" "C:\Program Files\Python312\python.exe" "C:\Program Files\Python311\python.exe" "C:\Program Files\Python310\python.exe") do (
  34. if exist %%~D (
  35. %%~D -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul
  36. if not errorlevel 1 (
  37. set "PY_EXE=%%~D"
  38. set "PY_ARGS="
  39. goto :py_found
  40. )
  41. )
  42. )
  43. )
  44. :py_found
  45. if not defined PY_EXE (
  46. echo Python3 interpreter not found.
  47. echo Current python version:
  48. python --version
  49. echo Please install Python 3.10+ and retry.
  50. echo Download URL https://www.python.org/downloads/windows/
  51. exit /b 1
  52. )
  53. echo Using interpreter:
  54. call "%PY_EXE%" %PY_ARGS% --version
  55. echo [1/3] Install dependencies...
  56. call :install_requirements
  57. if errorlevel 1 (
  58. echo Dependency install failed after trying all indexes
  59. exit /b 1
  60. )
  61. echo [2/3] Build EXE...
  62. if exist "dist\QMSFileCollector.exe" (
  63. del /f /q "dist\QMSFileCollector.exe" >nul 2>nul
  64. if exist "dist\QMSFileCollector.exe" (
  65. echo Existing dist\QMSFileCollector.exe is locked.
  66. echo Please close running QMSFileCollector process and retry.
  67. exit /b 1
  68. )
  69. )
  70. call "%PY_EXE%" %PY_ARGS% -m PyInstaller --noconfirm --clean --onefile --windowed --name QMSFileCollector client_file_collector.py
  71. if errorlevel 1 (
  72. echo EXE build failed
  73. exit /b 1
  74. )
  75. echo [3/3] Build completed
  76. echo Output: dist\QMSFileCollector.exe
  77. endlocal
  78. exit /b 0
  79. :install_requirements
  80. for %%I in (https://pypi.tuna.tsinghua.edu.cn/simple https://mirrors.aliyun.com/pypi/simple/ https://pypi.org/simple) do (
  81. echo Trying pip index: %%I
  82. call "%PY_EXE%" %PY_ARGS% -m pip install %PIP_INSTALL_ARGS% -i %%I -r requirements.txt
  83. if not errorlevel 1 (
  84. echo Dependencies installed from %%I
  85. exit /b 0
  86. )
  87. echo Install failed from %%I, try next index...
  88. )
  89. exit /b 1