diff --git a/tables/__init__.py b/tables/__init__.py index 29b81d523..3f1e9ef01 100644 --- a/tables/__init__.py +++ b/tables/__init__.py @@ -8,20 +8,23 @@ """ import os from ctypes import cdll +from ctypes.util import find_library import platform # Load the blosc2 library, and if not found in standard locations, # try this directory (it should be automatically copied in setup.py). -current_dir = os.path.dirname(__file__) -platform_system = platform.system() -blosc2_lib = "libblosc2" -if platform_system == "Linux": - blosc2_lib += ".so" -elif platform_system == "Darwin": - blosc2_lib += ".dylib" -else: - blosc2_lib += ".dll" +blosc2_lib = find_library("libblosc2") +if blosc2_lib is None: + current_dir = os.path.dirname(__file__) + platform_system = platform.system() + blosc2_lib = "libblosc2" + if platform_system == "Linux": + blosc2_lib += ".so" + elif platform_system == "Darwin": + blosc2_lib += ".dylib" + else: + blosc2_lib += ".dll" try: cdll.LoadLibrary(blosc2_lib) except OSError: