From 8301fc8ef49bc26dea53b03ca2f964fb60d7e64b Mon Sep 17 00:00:00 2001 From: Quality App Developer Date: Thu, 5 Feb 2026 11:32:21 +0200 Subject: [PATCH] Simplify build: use pyinstaller directly, add better error handling --- .github/workflows/build-windows.yml | 16 +++--------- build_exe.py | 39 ++++++++++++++++++----------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 66e6d6e..53a446e 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -24,22 +24,12 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip + python -m pip install --upgrade pip setuptools wheel pip install -r requirements_windows.txt - - name: Verify build setup - run: | - echo "Python version:" - python --version - echo "Installed packages:" - pip list - echo "Current directory:" - cd %CD% - echo "Files in directory:" - dir /B - - name: Build executable with PyInstaller - run: python build_exe.py + run: | + pyinstaller label_printer_gui.py --onefile --windowed --name=LabelPrinter --distpath=./dist --buildpath=./build --hidden-import=kivy --hidden-import=kivy.core.window --hidden-import=kivy.core.text --hidden-import=kivy.core.image --hidden-import=kivy.uix.boxlayout --hidden-import=kivy.uix.gridlayout --hidden-import=kivy.uix.label --hidden-import=kivy.uix.textinput --hidden-import=kivy.uix.button --hidden-import=kivy.uix.spinner --hidden-import=kivy.uix.scrollview --hidden-import=kivy.uix.popup --hidden-import=kivy.clock --hidden-import=kivy.graphics --hidden-import=PIL --hidden-import=barcode --hidden-import=reportlab --hidden-import=print_label --hidden-import=print_label_pdf - name: Upload Windows executable as artifact uses: actions/upload-artifact@v4 diff --git a/build_exe.py b/build_exe.py index 0c2165a..4a0d56e 100644 --- a/build_exe.py +++ b/build_exe.py @@ -7,14 +7,14 @@ If run on Linux/macOS, it will create a Linux/macOS binary that won't work on Wi To build for Windows: 1. Copy this project to a Windows machine -2. Install dependencies: pip install -r requirements_gui.txt +2. Install dependencies: pip install -r requirements_windows.txt 3. Run this script: python build_exe.py 4. The Windows .exe will be created in the dist/ folder """ import os import sys -from PyInstaller import __main__ as pyi_main +import subprocess # Get the current directory script_dir = os.path.dirname(os.path.abspath(__file__)) @@ -58,15 +58,26 @@ if __name__ == '__main__': # Change to script directory os.chdir(script_dir) - # Run PyInstaller - pyi_main.run(args) - - print("\n" + "=" * 60) - print("Build Complete!") - print("=" * 60) - print("\nExecutable location: ./dist/LabelPrinter.exe") - print("\nYou can now:") - print("1. Double-click LabelPrinter.exe to run") - print("2. Share the exe with others") - print("3. Create a shortcut on desktop") - print("\nNote: First run may take a moment as Kivy initializes") + # Run PyInstaller directly with subprocess for better error reporting + try: + result = subprocess.run(['pyinstaller'] + args, check=True) + + print("\n" + "=" * 60) + print("Build Complete!") + print("=" * 60) + print("\nExecutable location: ./dist/LabelPrinter.exe") + print("\nYou can now:") + print("1. Double-click LabelPrinter.exe to run") + print("2. Share the exe with others") + print("3. Create a shortcut on desktop") + print("\nNote: First run may take a moment as Kivy initializes") + except subprocess.CalledProcessError as e: + print("\n" + "=" * 60) + print("Build Failed!") + print("=" * 60) + print(f"\nError code: {e.returncode}") + print("\nPlease check the error messages above for details.") + sys.exit(1) + except Exception as e: + print(f"\nFatal error: {e}") + sys.exit(1)