Skip to content

Commit 2f9cd0e

Browse files
fix: hardcoded binary paths
1 parent 000d03b commit 2f9cd0e

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

main.spec

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
a = Analysis(
55
['src\\main.py'],
66
pathex=[],
7-
binaries=[('C:\\_My\\Projects\\Programming\\Python\\_My\\paste-bar-code\\.venv\\Lib\\site-packages\\pyzbar\\libiconv.dll', 'pyzbar'), ('C:\\_My\\Projects\\Programming\\Python\\_My\\paste-bar-code\\.venv\\Lib\\site-packages\\pyzbar\\libzbar-64.dll', 'pyzbar')],
7+
binaries=[],
88
datas=[('.\\src\\resources\\', 'resources')],
99
hiddenimports=[],
1010
hookspath=[],
@@ -14,6 +14,39 @@ a = Analysis(
1414
noarchive=False,
1515
optimize=0,
1616
)
17+
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'))
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+
1750
pyz = PYZ(a.pure)
1851

1952
exe = EXE(

0 commit comments

Comments
 (0)