Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find more liblsl variants #18

Merged
merged 13 commits into from
Nov 18, 2019
50 changes: 33 additions & 17 deletions pylsl/pylsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,24 +1179,40 @@ def resolve_stream(*args):
# === Module Initialization Code ===
# ==================================

# find and load library
os_name = platform.system()
bitness = 8 * struct.calcsize("P")
if os_name in ['Windows', 'Microsoft']:
libname = 'liblsl32.dll' if bitness == 32 else 'liblsl64.dll'
elif os_name == 'Darwin':
libname = 'liblsl32.dylib' if bitness == 32 else 'liblsl64.dylib'
elif os_name == 'Linux':
libname = 'liblsl32.so' if bitness == 32 else 'liblsl64.so'
else:
raise RuntimeError("unrecognized operating system:", os_name)
libpath = os.path.join(os.path.dirname(__file__), 'lib', libname)
if not os.path.isfile(libpath):
libpath = util.find_library('lsl' + str(bitness))
if not libpath:
raise RuntimeError("library " + libname + " was not found - make sure "
def find_liblsl_libraries():
# find and load library
os_name = platform.system()
if os_name in ['Windows', 'Microsoft']:
libsuffix = '.dll'
elif os_name == 'Darwin':
libsuffix = '.dylib'
elif os_name == 'Linux':
libsuffix = '.so'
else:
raise RuntimeError("unrecognized operating system:", os_name)

if 'PYLSL_LIB' in os.environ:
yield os.environ['PYLSL_LIB']
tstenner marked this conversation as resolved.
Show resolved Hide resolved

libbasepath = os.path.join(os.path.dirname(__file__), 'liblsl')
tstenner marked this conversation as resolved.
Show resolved Hide resolved
for debugsuffix in ['', '-debug']:
for bitness in ['', str(8 * struct.calcsize("P"))]:
path = libbasepath + bitness + debugsuffix + libsuffix
print(path)
if os.path.isfile(path):
yield path
path = util.find_library('lsl' + bitness + debugsuffix )
print(path)
if path is not None:
yield path


try:
libpath = next(find_liblsl_libraries())
except StopIteration:
raise RuntimeError("liblsl library was not found - make sure "
"that it is on the search path (e.g., in the same "
"folder as pylsl.py).")
"folder as pylsl.py or the system search path).")
lib = CDLL(libpath)


Expand Down