@echo off echo ==================================================== echo GeoMedical Helper App Build Script echo ==================================================== REM Get current timestamp for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "NN=%dt:~10,2%" & set "SS=%dt:~12,2%" set "timestamp=%YYYY%-%MM%-%DD% %HH%:%NN%:%SS%" echo Build started: %timestamp% echo. REM Check Python and PyInstaller echo Checking environment... python --version >nul 2>&1 if errorlevel 1 ( echo ERROR: Python is not installed or not in PATH pause exit /b 1 ) pyinstaller --version >nul 2>&1 if errorlevel 1 ( echo WARNING: PyInstaller not found. Installing... pip install pyinstaller if errorlevel 1 ( echo ERROR: PyInstaller installation failed pause exit /b 1 ) ) echo OK: Python environment ready echo. REM Install required libraries echo Installing required libraries... pip install -r requirements.txt if errorlevel 1 ( echo WARNING: Some libraries failed to install (optional libraries ignored) ) echo. REM Clean previous build echo Cleaning previous build... if exist "dist" rmdir /s /q "dist" if exist "build" rmdir /s /q "build" if exist "app.exe" del "app.exe" echo OK: Cleanup complete echo. REM Build with PyInstaller echo Starting PyInstaller build... echo Command: pyinstaller app.spec --clean --noconfirm pyinstaller app.spec --clean --noconfirm if errorlevel 1 ( echo ERROR: Build failed! echo. echo Troubleshooting: echo 1. Check Python path: python --version echo 2. Check libraries: pip list echo 3. Check spec file: app.spec echo 4. Check logs: build folder echo. pause exit /b 1 ) REM Check build result if not exist "dist\app.exe" ( echo ERROR: app.exe was not created! pause exit /b 1 ) REM Check file size for %%I in ("dist\app.exe") do set SIZE=%%~zI set /a SIZE_MB=%SIZE%/1024/1024 echo OK: Build successful! echo File location: dist\app.exe echo File size: %SIZE_MB% MB (%SIZE% bytes) echo. REM Copy to current directory echo Copying deployment file... copy "dist\app.exe" "app.exe" >nul if exist "app.exe" ( echo OK: Deployment app.exe copied ) else ( echo ERROR: File copy failed ) echo. REM Build completion info echo ==================================================== echo Build Complete! echo ==================================================== echo Deployment file: app.exe echo File size: %SIZE_MB% MB echo Build time: %timestamp% echo. echo Next steps: echo 1. Test app.exe execution echo 2. Upload app.exe to server echo 3. Update version.json echo 4. Deploy to agent PCs echo. REM Auto-run option set /p choice="Run built app.exe now? (y/N): " if /i "%choice%"=="y" ( echo Running... start "" "app.exe" ) else ( echo Run manually: app.exe ) echo. echo Build script completed pause