Skip to content

Commit 54d8144

Browse files
Fix for linux - lib name and paths (#151)
* fix for linux * fix for linux, lib paths * fix for linux, name convention
1 parent ac70b2b commit 54d8144

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pypicosdk/base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import ctypes
66
import os
7+
import platform
78
import warnings
89

910
import numpy as np
@@ -38,7 +39,18 @@ def __init__(self, dll_name, *args, **kwargs):
3839
if self._pytest:
3940
self.dll = None
4041
else:
41-
self.dll = ctypes.CDLL(os.path.join(_get_lib_path(), dll_name + ".dll"))
42+
# Determine file extension and naming convention based on OS
43+
system = platform.system()
44+
if system == "Windows":
45+
lib_name = dll_name + ".dll"
46+
elif system == "Linux":
47+
lib_name = "lib" + dll_name + ".so"
48+
elif system == "Darwin":
49+
lib_name = "lib" + dll_name + ".dylib"
50+
else:
51+
lib_name = "lib" + dll_name + ".so" # Default to Unix-like naming
52+
53+
self.dll = ctypes.CDLL(os.path.join(_get_lib_path(), lib_name))
4254
self._unit_prefix_n = dll_name
4355

4456
# Setup class variables

pypicosdk/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _get_lib_path() -> str:
7979
]
8080
return _check_path(program_files, checklist)
8181
elif system == "Linux":
82-
return _check_path('opt', 'picoscope')
82+
return _check_path('/opt', ['picoscope/lib'])
8383
elif system == "Darwin":
8484
raise PicoSDKException("macOS is not yet tested and supported")
8585
else:

0 commit comments

Comments
 (0)