Skip to content

Commit 6f9f261

Browse files
committed
[Python] Fix lib loading/path search for non-linux platforms
1 parent c5596ae commit 6f9f261

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

python/pycubool/wrapper.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,35 @@ class Wrapper:
4444

4545
def __init__(self):
4646
self.loaded_dll = None
47-
self.lib_object_name = "libcubool.so"
4847

4948
try:
5049
# Try from config if present
5150
self.load_path = os.environ["CUBOOL_PATH"]
5251
except KeyError:
5352
# Fallback to package directory
5453
source_path = pathlib.Path(__file__).resolve()
55-
self.load_path = str(source_path.parent / self.lib_object_name)
54+
self.load_path = Wrapper.__get_lib_path(source_path.parent)
55+
56+
assert self.load_path
5657

5758
self.loaded_dll = bridge.load_and_configure(self.load_path)
58-
self._setup_library()
59+
self.__setup_library()
5960

6061
def __del__(self):
61-
self._release_library()
62-
pass
62+
self.__release_library()
6363

64-
def _setup_library(self):
64+
def __setup_library(self):
6565
status = self.loaded_dll.cuBool_Initialize(ctypes.c_uint(bridge.get_init_hints(False, False)))
6666
bridge.check(status)
6767

68-
def _release_library(self):
68+
def __release_library(self):
6969
status = self.loaded_dll.cuBool_Finalize()
7070
bridge.check(status)
71+
72+
@classmethod
73+
def __get_lib_path(cls, prefix):
74+
for entry in os.listdir(prefix):
75+
if "cubool" in str(entry):
76+
return prefix / entry
77+
78+
return None

0 commit comments

Comments
 (0)