build_exe.bat 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. cd /d "%~dp0.."
  4. echo ==========================================
  5. echo DZXJ DTU - build Windows portable exe
  6. echo ==========================================
  7. where python >nul 2>nul
  8. if errorlevel 1 (
  9. echo [ERROR] python not found in PATH. Install Python 3.10+ first.
  10. exit /b 1
  11. )
  12. echo [1/4] check frontend\dist ...
  13. if not exist "frontend\dist\index.html" (
  14. echo frontend\dist missing, building ...
  15. pushd frontend
  16. call npm install
  17. if errorlevel 1 (popd & exit /b 1)
  18. call npm run build
  19. if errorlevel 1 (popd & exit /b 1)
  20. popd
  21. )
  22. echo [2/4] prepare venv .venv-exe and install deps ...
  23. if not exist ".venv-exe\Scripts\python.exe" python -m venv .venv-exe
  24. call ".venv-exe\Scripts\activate.bat"
  25. python -m pip install --upgrade pip
  26. python -m pip install -r packaging\requirements_windows.txt
  27. if errorlevel 1 exit /b 1
  28. echo [3/4] pyinstaller onefile build ...
  29. python -m PyInstaller --noconfirm --clean --distpath dist --workpath build\pyinstaller packaging\dzxj_dtu.spec
  30. if errorlevel 1 exit /b 1
  31. echo [4/4] done
  32. echo output: %CD%\dist\dzxj_dtu.exe
  33. dir /b dist\dzxj_dtu.exe
  34. exit /b 0