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.
|
|
@echo offchcp 65001 >nulsetlocal EnableDelayedExpansion
set "PY_EXE="set "PY_ARGS="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"
where py >nul 2>nulif not errorlevel 1 ( py -3 -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul if not errorlevel 1 ( set "PY_EXE=py" set "PY_ARGS=-3" ))
if not defined PY_EXE ( where python3 >nul 2>nul if not errorlevel 1 ( python3 -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul if not errorlevel 1 ( set "PY_EXE=python3" set "PY_ARGS=" ) ))
if not defined PY_EXE ( python -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul if not errorlevel 1 ( set "PY_EXE=python" set "PY_ARGS=" ))
if not defined PY_EXE ( 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 ( if exist %%~D ( %%~D -c "import sys;sys.exit(0 if sys.version_info[0]>=3 else 1)" >nul 2>nul if not errorlevel 1 ( set "PY_EXE=%%~D" set "PY_ARGS=" goto :py_found ) ) ))
:py_foundif not defined PY_EXE ( echo Python3 interpreter not found. echo Current python version: python --version echo Please install Python 3.10+ and retry. echo Download URL https://www.python.org/downloads/windows/ exit /b 1)
echo Using interpreter:call "%PY_EXE%" %PY_ARGS% --version
echo [1/3] Install dependencies...call :install_requirementsif errorlevel 1 ( echo Dependency install failed after trying all indexes exit /b 1)
echo [2/3] Build EXE...if exist "dist\QMSFileCollector.exe" ( del /f /q "dist\QMSFileCollector.exe" >nul 2>nul if exist "dist\QMSFileCollector.exe" ( echo Existing dist\QMSFileCollector.exe is locked. echo Please close running QMSFileCollector process and retry. exit /b 1 ))call "%PY_EXE%" %PY_ARGS% -m PyInstaller --noconfirm --clean --onefile --windowed --name QMSFileCollector client_file_collector.pyif errorlevel 1 ( echo EXE build failed exit /b 1)
echo [3/3] Build completedecho Output: dist\QMSFileCollector.exeendlocalexit /b 0
:install_requirementsfor %%I in (https://pypi.tuna.tsinghua.edu.cn/simple https://mirrors.aliyun.com/pypi/simple/ https://pypi.org/simple) do ( echo Trying pip index: %%I call "%PY_EXE%" %PY_ARGS% -m pip install %PIP_INSTALL_ARGS% -i %%I -r requirements.txt if not errorlevel 1 ( echo Dependencies installed from %%I exit /b 0 ) echo Install failed from %%I, try next index...)exit /b 1
|