Skip to content

Commit

Permalink
search for libblosc2 with pkg-config if not in the python blosc2 inst…
Browse files Browse the repository at this point in the history
…allation
  • Loading branch information
bnavigator committed Feb 19, 2023
1 parent aafa0fc commit 73770df
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions setup.py
Expand Up @@ -97,11 +97,12 @@ def get_blosc2_version(headername):


def get_blosc2_directories():
"""Get Blosc2 directories for the C library by using wheel metadata"""
"""Get Blosc2 directories for the C library"""
try:
import blosc2
except ModuleNotFoundError:
raise EnvironmentError("Cannot import the blosc2 requirement")
# The published wheels package the c-blosc2 library directly
version = blosc2.__version__
basepath = Path(os.path.dirname(blosc2.__file__))
recinfo = basepath.parent / f'blosc2-{version}.dist-info' / 'RECORD'
Expand All @@ -111,10 +112,18 @@ def get_blosc2_directories():
library_path = Path(os.path.abspath(basepath.parent /
Path(line[:line.find('libblosc2')])))
break
if not library_path:
raise NotADirectoryError("Library directory not found for blosc2!")
if library_path:
include_path = library_path.parent / 'include'
else:
# Linux distributions like to package the library separately, search by pkg-config
try:
cmd = [PKG_CONFIG, '--variable=libdir', 'blosc2']
library_path = Path(subprocess.check_output(cmd, text=True).strip())
cmd = [PKG_CONFIG, '--variable=includedir', 'blosc2']
include_path = Path(subprocess.check_output(cmd, text=True).strip())
except CalledProcessError as e:
raise NotADirectoryError("Library directory not found for blosc2!") from e

include_path = library_path.parent / 'include'
if not os.path.isfile(include_path / 'blosc2.h'):
install_path = os.path.abspath(library_path.parent)
raise NotADirectoryError(
Expand Down Expand Up @@ -841,7 +850,7 @@ def find_runtime_path(self, locations=default_runtime_dirs):
shared_libs = glob.glob(str(libdir) + '/libblosc2*.dylib')
for lib in shared_libs:
shutil.copy(lib, dll_dir)

else:
copy_libs += ['libblosc2.dll']
dll_dir = 'C:\\Miniconda\\envs\\build\\Library\\bin'
Expand Down

0 comments on commit 73770df

Please sign in to comment.