Skip to content

Commit 12b3ea9

Browse files
committed
Find LpcCrOSEC.bin while frozen with PyInstaller
1 parent 736ec98 commit 12b3ea9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cros_ec_python/devices/pawnio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import warnings
33
import ctypes
44
import os
5+
import sys
56
from ctypes import wintypes
67
from ctypes import util as ctypes_util
78

@@ -22,7 +23,10 @@ def __init__(self, dll: str | None = None, bin: str | None = None):
2223
:param bin: Path to the binary to load. If None, will use the default path.
2324
"""
2425

25-
self.bin = bin or "LpcCrOSEC.bin"
26+
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
27+
self.bin = bin or os.path.join(sys._MEIPASS, "LpcCrOSEC.bin")
28+
else:
29+
self.bin = bin or "LpcCrOSEC.bin"
2630

2731
if dll or (dll := ctypes_util.find_library("PawnIOLib.dll")):
2832
self.pawniolib = ctypes.OleDLL(dll)

0 commit comments

Comments
 (0)