Files
adaptronic_label-printer/build_windows.bat

120 lines
3.7 KiB
Batchfile

@echo off
REM Label Printer - Windows Build Script (Single File EXE)
REM This script builds a standalone LabelPrinter.exe on Windows
REM Requirements: Python 3.10-3.13 installed and in PATH
REM Note: Python 3.14+ may have compatibility issues
setlocal enabledelayedexpansion
echo.
echo ========================================================
echo Label Printer - Windows Build Script
echo Creates: LabelPrinter.exe (Single File)
echo ========================================================
echo.
REM Check if Python is installed
python --version >nul 2>&1
if errorlevel 1 (
echo ERROR: Python is not installed or not in PATH
echo Please install Python 3.10-3.13 from https://www.python.org/
echo Make sure to check "Add Python to PATH" during installation
pause
exit /b 1
)
echo [1/6] Checking Python installation...
python --version
echo.
REM Upgrade pip
echo [2/6] Upgrading pip, setuptools, and wheel...
python -m pip install --upgrade pip setuptools wheel
if errorlevel 1 (
echo ERROR: Failed to upgrade pip
pause
exit /b 1
)
echo.
REM Install dependencies
echo [3/6] Installing dependencies...
echo Installing: python-barcode, pillow, reportlab, kivy, pyinstaller, pywin32, wmi, watchdog, svglib, cairosvg, pystray...
pip install python-barcode pillow reportlab kivy pyinstaller pywin32 wmi watchdog svglib cairosvg pystray
if errorlevel 1 (
echo ERROR: Failed to install dependencies
pause
exit /b 1
)
echo.
REM Copy GhostScript binaries for bundling (optional but strongly recommended)
echo [4/6] Preparing GhostScript for bundling...
python prepare_ghostscript.py
echo.
REM Check that SumatraPDF.exe exists before building
if not exist "conf\SumatraPDF.exe" (
echo ERROR: conf\SumatraPDF.exe not found!
echo Please download SumatraPDF portable exe and place it at conf\SumatraPDF.exe
echo Download from: https://www.sumatrapdfreader.org/download-free-pdf-viewer
pause
exit /b 1
)
echo conf\SumatraPDF.exe found - will be bundled into executable.
echo.
REM Clean old build (keep the spec file - it's handcrafted)
echo [5/6] Cleaning old build artifacts...
if exist "dist" rmdir /s /q dist
if exist "build" rmdir /s /q build
echo.
REM Build with PyInstaller using the spec file.
REM The spec (LabelPrinter.spec) contains Python code that detects whether
REM conf\ghostscript\ was prepared and includes those files automatically.
echo [6/6] Building executable with PyInstaller...
echo This may take 5-15 minutes, please wait...
echo.
pyinstaller LabelPrinter.spec --distpath=./dist --workpath=./build -y
if errorlevel 1 (
echo.
echo ERROR: Build failed!
echo Please check the error messages above.
pause
exit /b 1
)
echo.
echo ========================================================
echo BUILD SUCCESSFUL!
echo ========================================================
echo.
echo Copying conf folder to dist\conf ...
if exist dist\conf rmdir /s /q dist\conf
xcopy /e /i /q conf dist\conf
if errorlevel 1 (
echo WARNING: Could not copy conf folder to dist\conf
echo You must manually copy the conf folder next to LabelPrinter.exe before deployment.
) else (
echo conf folder copied to dist\conf successfully.
)
echo.
echo Executable Location: dist\LabelPrinter.exe
echo.
echo Deployment folder contents:
dir dist
echo.
echo Next steps:
echo 1. Copy the entire dist\ folder to the target machine
echo (it contains LabelPrinter.exe AND the conf\ folder)
echo 2. Run LabelPrinter.exe from the dist folder
echo 3. GhostScript is bundled inside the exe for sharp vector printing
echo 4. SumatraPDF (conf\SumatraPDF.exe) is also bundled as fallback
echo.
echo Note: First run may take a moment as Kivy initializes
echo.
pause