REM === 本脚本为辅助工具,主启动请用 start.bat === @echo off chcp 65001 >nul 2>&1 title ShuiLi ZhiXue - EXE Builder echo ======================================== echo ShuiLi ZhiXue System - EXE Builder echo ======================================== echo. cd /d "%~dp0" REM Check Python python --version >nul 2>&1 if errorlevel 1 ( echo [ERROR] Python not found. Please install Python 3.9+ first. echo Download: https://www.python.org/downloads/ pause exit /b 1 ) REM Install project dependencies first echo [0/3] Installing project dependencies... python -m pip install -r requirements.txt if errorlevel 1 ( echo [ERROR] Failed to install project dependencies. pause exit /b 1 ) REM Check and install PyInstaller python -m pip show pyinstaller >nul 2>&1 if errorlevel 1 ( echo [1/3] Installing PyInstaller... python -m pip install pyinstaller if errorlevel 1 ( echo [ERROR] Failed to install PyInstaller. pause exit /b 1 ) ) else ( echo [1/3] PyInstaller already installed. ) REM Clean old build files echo. echo [2/3] Cleaning old build files... if exist build rmdir /s /q build if exist dist rmdir /s /q dist if exist "shuili_zhixue.spec" del /q "shuili_zhixue.spec" REM Build EXE echo. echo [3/3] Building EXE (this may take 2-5 minutes)... echo. python -m PyInstaller --onefile --name "shuili_zhixue" --noconsole ^ --add-data "backend;backend" ^ --add-data "frontend;frontend" ^ --hidden-import uvicorn.logging ^ --hidden-import uvicorn.loops ^ --hidden-import uvicorn.loops.auto ^ --hidden-import uvicorn.protocols ^ --hidden-import uvicorn.protocols.http ^ --hidden-import uvicorn.protocols.http.auto ^ --hidden-import uvicorn.lifespan ^ --hidden-import uvicorn.lifespan.on ^ --collect-all fastapi ^ --collect-all sqlalchemy ^ --collect-all bcrypt ^ launcher.py if errorlevel 1 ( echo. echo [ERROR] Build failed! pause exit /b 1 ) echo. echo ======================================== echo Build SUCCESS! echo Output: dist\shuili_zhixue.exe echo ======================================== echo. echo Note: The exe will create data/, uploads/, backups/, logs/ folders echo in the same directory when first run. echo Default account: admin / admin123 echo. pause