This commit is contained in:
2026-02-23 17:07:00 +02:00
parent cbf324eb76
commit 7a77199fcf
7 changed files with 433 additions and 92 deletions

View File

@@ -1,12 +1,70 @@
# -*- mode: python ; coding: utf-8 -*-
#
# LabelPrinter PyInstaller spec file.
#
# GhostScript bundling
# --------------------
# Run build_windows.bat (or prepare_ghostscript.bat) BEFORE pyinstaller.
# That script copies the following directories from the system
# GhostScript installation into conf\ghostscript\:
#
# conf\ghostscript\bin\ <- gswin64c.exe + gsdll64.dll
# conf\ghostscript\lib\ <- all .ps init files
#
# This spec detects those directories automatically and adds them to the
# bundle under ghostscript\bin\ and ghostscript\lib\ inside _MEIPASS so
# that print_label.py can find and launch the bundled executable.
# If the directories are absent the build still succeeds (prints will fall
# back to SumatraPDF on the target machine).
import os
import glob as _glob
# ── GhostScript: collect binaries and lib init files ──────────────────────
_gs_bin_src = os.path.join('conf', 'ghostscript', 'bin')
_gs_lib_src = os.path.join('conf', 'ghostscript', 'lib')
gs_binaries = [] # (src_path, dest_folder_in_bundle)
gs_datas = [] # (src_path, dest_folder_in_bundle)
if os.path.isdir(_gs_bin_src):
for _fn in ['gswin64c.exe', 'gsdll64.dll', 'gswin32c.exe', 'gsdll32.dll']:
_fp = os.path.join(_gs_bin_src, _fn)
if os.path.exists(_fp):
# Put executables/DLLs in binaries so PyInstaller handles deps
gs_binaries.append((_fp, 'ghostscript/bin'))
print(f'[spec] Bundling GhostScript binaries from: {_gs_bin_src}')
else:
print('[spec] WARNING: conf/ghostscript/bin not found.'
' GhostScript will NOT be bundled in the exe.')
if os.path.isdir(_gs_lib_src):
for _fp in _glob.glob(os.path.join(_gs_lib_src, '*')):
if os.path.isfile(_fp):
gs_datas.append((_fp, 'ghostscript/lib'))
print(f'[spec] Bundling GhostScript lib from: {_gs_lib_src}')
# ── Base data files ────────────────────────────────────────────────────────
base_datas = [
('conf\\SumatraPDF.exe', '.'),
('conf\\SumatraPDF-settings.txt', 'conf'),
('conf\\label_template_ok.svg', 'conf'),
('conf\\label_template_nok.svg', 'conf'),
('conf\\label_template.svg', 'conf'),
]
a = Analysis(
['label_printer_gui.py'],
pathex=[],
binaries=[],
datas=[('conf\\SumatraPDF.exe', '.'), ('conf\\SumatraPDF-settings.txt', 'conf'), ('conf\\label_template_ok.svg', 'conf'), ('conf\\label_template_nok.svg', 'conf'), ('conf\\label_template.svg', 'conf')],
hiddenimports=['kivy', 'PIL', 'barcode', 'reportlab', 'print_label', 'print_label_pdf', 'svglib', 'cairosvg', 'watchdog', 'watchdog.observers', 'watchdog.events', 'pystray', 'win32timezone'],
binaries=gs_binaries,
datas=base_datas + gs_datas,
hiddenimports=[
'kivy', 'PIL', 'barcode', 'reportlab',
'print_label', 'print_label_pdf',
'svglib', 'cairosvg',
'watchdog', 'watchdog.observers', 'watchdog.events',
'pystray', 'win32timezone',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],