Skip to content

Commit

Permalink
Check Library/bin path exists before adding dll directory
Browse files Browse the repository at this point in the history
  • Loading branch information
daara-s committed Oct 16, 2024
1 parent cffe894 commit 795ce90
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/treelite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def _load_lib():
return None # type: ignore
if sys.version_info >= (3, 8) and sys.platform == "win32":
# pylint: disable=no-member
os.add_dll_directory(
os.path.join(os.path.normpath(sys.base_prefix), "Library", "bin")
)
lib_bin_path = os.path.join(os.path.normpath(sys.base_prefix), "Library", "bin")
if os.path.isdir(lib_bin_path):
os.add_dll_directory(lib_bin_path)

Check warning on line 38 in python/treelite/core.py

View check run for this annotation

Codecov / codecov/patch

python/treelite/core.py#L36-L38

Added lines #L36 - L38 were not covered by tests

lib = ctypes.cdll.LoadLibrary(lib_path[0])
lib.TreeliteGetLastError.restype = ctypes.c_char_p
lib.log_callback = _log_callback
Expand Down

0 comments on commit 795ce90

Please sign in to comment.