From 72c6fa605ed3301f7679d47d65a36251cf828a26 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Mon, 15 Jun 2026 21:59:24 +0200 Subject: [PATCH] refactor(lib): remove duplicated library-search blocks The 'active Python env lib dir' and 'macOS Frameworks' search blocks in find_liblsl_libraries were each present twice, verbatim. The generator is consumed with next(), so the second copy could only ever yield a path already yielded by the first - it was dead code. Removing it drops up to 8 redundant os.path.isfile() calls on the library-not-found fallback path and leaves the set and order of yielded paths unchanged. --- src/pylsl/lib/__init__.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/pylsl/lib/__init__.py b/src/pylsl/lib/__init__.py index 7daf872..b602743 100644 --- a/src/pylsl/lib/__init__.py +++ b/src/pylsl/lib/__init__.py @@ -136,30 +136,6 @@ def find_liblsl_libraries(verbose=False): if os.path.isfile(path): yield path - # The active Python env's lib directory (e.g. `conda install -c conda-forge - # liblsl` lands here). ctypes.util.find_library doesn't search here. - env_libdir = os.path.join(sys.prefix, "lib") - for libprefix in ["", "lib"]: - for debugsuffix in ["", "-debug"]: - path = os.path.join(env_libdir, libprefix + "lsl" + debugsuffix + libsuffix) - if os.path.isfile(path): - yield path - - # macOS Frameworks (e.g. installed via `brew install labstreaminglayer/tap/lsl`) - # aren't found by ctypes.util.find_library, but the framework binary is a - # regular dylib that ctypes.CDLL can load directly. - if os_name == "Darwin": - framework_roots = [ - "/opt/homebrew/Frameworks", # Apple Silicon homebrew - "/usr/local/Frameworks", # Intel homebrew - os.path.expanduser("~/Library/Frameworks"), - "/Library/Frameworks", - ] - for root in framework_roots: - path = os.path.join(root, "lsl.framework", "lsl") - if os.path.isfile(path): - yield path - __dload_msg = ( "You can install the LSL library with conda: `conda install -c conda-forge liblsl`"