Skip to content

Commit

Permalink
Changed adslib DLL finder logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-DEMCON authored and RobertoRoos committed Sep 23, 2024
1 parent f8707ba commit 80d9607
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/pyads/pyads_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@
)

elif platform_is_linux():
# try to load local adslib.so in favor to global one
local_adslib = os.path.join(os.path.dirname(__file__), "adslib.so")
if os.path.isfile(local_adslib):
adslib = local_adslib
else:
adslib = "adslib.so"
adslib_path = None

_adsDLL = ctypes.CDLL(adslib)
for p in sys.path:
adslib_path = os.path.join(p, "adslib.so")
if os.path.exists(adslib_path):
break

if adslib_path is None:
raise OSError(f"Failed to locate `adslib.so` library in {sys.path}")

# For some reason loading on just "adslib.so" always fails, even if it is under
# sys.path, so manually search for it first
_adsDLL = ctypes.CDLL(adslib_path)

NOTEFUNC = ctypes.CFUNCTYPE(
None,
Expand Down

0 comments on commit 80d9607

Please sign in to comment.