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 committed Sep 20, 2024
1 parent 70adf39 commit 0ed8e6e
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 @@ -79,14 +79,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 0ed8e6e

Please sign in to comment.