11# -*- mode: python ; coding: utf-8 -*-
22
3+ # region Prepare pyzbar dll paths to add them to binaries.
4+ # NOTE: tried adding 'pyzbar' to hiddenimports. but didn't work for some reason.
5+ from pathlib import Path
6+
7+ import pyzbar
8+
9+ pyzbar_path = Path (pyzbar .__file__ ).parent
10+ libiconv_dll_path = pyzbar_path / "libiconv.dll"
11+ libzbar_64_dll_path = pyzbar_path / "libzbar-64.dll"
12+ # endregion
313
414a = Analysis (
515 ['src\\ main.py' ],
616 pathex = [],
7- binaries = [],
17+ binaries = [( libiconv_dll_path . as_posix (), "pyzbar" ), ( libzbar_64_dll_path . as_posix (), "pyzbar" ) ],
818 datas = [('.\\ src\\ resources\\ ' , 'resources' )],
919 hiddenimports = [],
1020 hookspath = [],
@@ -15,38 +25,6 @@ a = Analysis(
1525 optimize = 0 ,
1626)
1727
18- # Add pyzbar DLLs dynamically if they exist
19- import os
20- import sys
21- from pathlib import Path
22-
23- def find_pyzbar_dlls ():
24- """Find pyzbar DLLs in the current environment"""
25- dlls = []
26- try :
27- # Try to find pyzbar site-packages
28- import pyzbar
29- pyzbar_path = Path (pyzbar .__file__ ).parent
30-
31- # Look for DLLs in pyzbar directory
32- for dll_name in ['libiconv.dll' , 'libzbar-64.dll' ]:
33- dll_path = pyzbar_path / dll_name
34- if dll_path .exists ():
35- dlls .append ((str (dll_path ), 'pyzbar' , 'BINARY' ))
36- else :
37- print (f"Warning: { dll_name } not found at { dll_path } " )
38- except ImportError :
39- print ("Warning: pyzbar not found during spec processing" )
40- except Exception as e :
41- print (f"Warning: Error finding pyzbar DLLs: { e } " )
42-
43- return dlls
44-
45- # Add DLLs to binaries
46- pyzbar_dlls = find_pyzbar_dlls ()
47- if pyzbar_dlls :
48- a .binaries .extend (pyzbar_dlls )
49-
5028pyz = PYZ (a .pure )
5129
5230exe = EXE (
@@ -56,6 +34,7 @@ exe = EXE(
5634 a .datas ,
5735 [],
5836 name = 'Paste Bar Code' ,
37+ icon = 'src/resources/icon.ico' ,
5938 debug = False ,
6039 bootloader_ignore_signals = False ,
6140 strip = False ,
0 commit comments