@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/5] Checking Python installation... python --version echo. REM Upgrade pip echo [2/5] 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/5] 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 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 echo [4/5] Cleaning old build artifacts... if exist "dist" rmdir /s /q dist if exist "build" rmdir /s /q build if exist "*.spec" del *.spec echo. REM Build with PyInstaller echo [5/5] Building executable with PyInstaller... echo This may take 5-15 minutes, please wait... echo. pyinstaller label_printer_gui.py ^ --onefile ^ --windowed ^ --name=LabelPrinter ^ --distpath=./dist ^ --workpath=./build ^ --hidden-import=kivy ^ --hidden-import=PIL ^ --hidden-import=barcode ^ --hidden-import=reportlab ^ --hidden-import=print_label ^ --hidden-import=print_label_pdf ^ --hidden-import=svglib ^ --hidden-import=cairosvg ^ --hidden-import=watchdog ^ --hidden-import=watchdog.observers ^ --hidden-import=watchdog.events ^ --hidden-import=pystray ^ --hidden-import=win32timezone ^ --add-data "conf\SumatraPDF.exe;." ^ --add-data "conf\SumatraPDF-settings.txt;conf" ^ --add-data "conf\label_template_ok.svg;conf" ^ --add-data "conf\label_template_nok.svg;conf" ^ --add-data "conf\label_template.svg;conf" ^ -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. Ensure conf\SumatraPDF.exe is present for printing to work echo. echo Note: First run may take a moment as Kivy initializes echo. pause