File hdf5plugin-system-libs.patch of Package python-hdf5plugin
diff -ur hdf5plugin-4.4.0.orig/setup.py hdf5plugin-4.4.0/setup.py
--- hdf5plugin-4.4.0.orig/setup.py 2024-03-04 12:16:31.477614501 +0100
+++ hdf5plugin-4.4.0/setup.py 2024-03-04 19:29:27.677632537 +0100
@@ -31,6 +31,7 @@
import itertools
import logging
import os
+import subprocess
import sys
import sysconfig
import tempfile
@@ -146,32 +147,21 @@
self.__compiler = get_compiler(compiler)
# Set architecture specific compile args
- if self.ARCH in ('X86_32', 'X86_64', 'MIPS_64'):
- self.native_compile_args = ("-march=native",)
- elif self.ARCH in ('ARM_7', 'ARM_8', 'PPC_64'):
- self.native_compile_args = ("-mcpu=native",)
- else:
- self.native_compile_args = ()
+ self.native_compile_args = ()
if self.ARCH in ('X86_32', 'X86_64'):
self.sse2_compile_args = ('-msse2',) # /arch:SSE2 is on by default
else:
self.sse2_compile_args = ()
- if self.ARCH in ('X86_32', 'X86_64'):
- self.ssse3_compile_args = ('-mssse3',) # There is no /arch:SSSE3
- else:
- self.ssse3_compile_args = ()
+ self.ssse3_compile_args = ()
if self.ARCH in ('X86_32', 'X86_64'):
self.avx2_compile_args = ('-mavx2', '/arch:AVX2')
else:
self.avx2_compile_args = ()
- if self.ARCH in ('X86_32', 'X86_64'):
- self.avx512_compile_args = ('-mavx512f', '-mavx512bw', '/arch:AVX512')
- else:
- self.avx512_compile_args = ()
+ self.avx512_compile_args = ()
def get_shared_lib_extension(self) -> str:
"""Returns shared library file extension"""
@@ -208,13 +198,7 @@
def has_ssse3(self) -> bool:
"""Check SSSE3 availability on host"""
- if self.ARCH in ('X86_32', 'X86_64'):
- if not has_cpu_flag('ssse3'):
- return False # SSSE3 not available on host
- if self.__compiler.compiler_type == "msvc":
- return True
- return check_compile_flags(self.__compiler, "-mssse3")
- return False # Disabled by default
+ return False # SSE3 not available on openSUSE non hwcaps libs
def has_avx2(self) -> bool:
"""Check AVX2 availability on host"""
@@ -228,13 +212,7 @@
def has_avx512(self) -> bool:
"""Check AVX512 "F" and "BW" instruction sets availability on host"""
- if self.ARCH in ('X86_32', 'X86_64'):
- if not (has_cpu_flag('avx512f') and has_cpu_flag('avx512bw')):
- return False # AVX512 F and/or BW not available on host
- if self.__compiler.compiler_type == 'msvc':
- return True
- return check_compile_flags(self.__compiler, '-mavx512f', '-mavx512bw')
- return False # Disabled by default
+ return False # Disabled on openSUSE non hwcaps libs
def has_openmp(self) -> bool:
"""Check OpenMP availability on host"""
@@ -716,40 +694,62 @@
if BuildConfig.INTEL_IPP_DIR is not None:
return _get_lz4_ipp_clib(field)
- cflags = ['-O3', '-ffast-math', '-std=gnu99']
- cflags += ['/Ox', '/fp:fast']
+ if os.environ.get('HDF5PLUGIN_SYSTEM_LZ4', None):
+ config = dict(
+ sources=[],
+ include_dirs=[subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'liblz4']
+ )],
+ cflags=[],
+ )
+ libraries = [l.strip()[2:] for l in subprocess.check_output(
+ ["pkg-config", '--libs', 'liblz4']
+ ).decode().strip().split(" ")]
+ else:
+ cflags = ['-O3', '-ffast-math', '-std=gnu99']
+ cflags += ['/Ox', '/fp:fast']
- lz4_dir = glob('src/c-blosc2/internal-complibs/lz4*')[0]
+ lz4_dir = glob('src/c-blosc2/internal-complibs/lz4*')[0]
- config = dict(
- sources=glob(f'{lz4_dir}/*.c'),
- include_dirs=[lz4_dir],
- cflags=cflags,
- )
+ config = dict(
+ sources=glob(f'{lz4_dir}/*.c'),
+ include_dirs=[lz4_dir],
+ cflags=cflags,
+ )
+ libraries = []
if field is None:
return 'lz4', config
if field == 'extra_link_args':
return []
if field == 'libraries':
- return []
+ return libraries
return config[field]
def get_snappy_clib(field=None):
"""snappy static lib build config"""
- snappy_dir = 'src/snappy'
+ if os.environ.get('HDF5PLUGIN_SYSTEM_SNAPPY', None):
+ config = dict(
+ sources=[],
+ include_dirs=[subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'snappy']
+ )],
+ cflags=[],
+ )
+ else:
+ snappy_dir = 'src/snappy'
- config = dict(
- sources=prefix(snappy_dir, [
- 'snappy-c.cc',
- 'snappy-sinksource.cc',
- 'snappy-stubs-internal.cc',
- 'snappy.cc',
- ]),
- include_dirs=[snappy_dir],
- cflags=['-std=c++11'],
- )
+ config = dict(
+ sources=prefix(snappy_dir, [
+ 'snappy-c.cc',
+ 'snappy-sinksource.cc',
+ 'snappy-stubs-internal.cc',
+ 'snappy.cc',
+ ]),
+ include_dirs=[snappy_dir],
+ cflags=['-std=c++11'],
+ )
if field is None:
return 'snappy', config
@@ -777,40 +777,62 @@
def get_zlib_clib(field=None):
"""ZLib static lib build config"""
- cflags = ['-O3', '-ffast-math', '-std=gnu99']
- cflags += ['/Ox', '/fp:fast']
+ if os.environ.get('HDF5PLUGIN_SYSTEM_ZLIB', None):
+ config = dict(
+ sources=[],
+ include_dirs=[subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'zlib']
+ )],
+ cflags=[]
+ )
+ else:
+ cflags = ['-O3', '-ffast-math', '-std=gnu99']
+ cflags += ['/Ox', '/fp:fast']
- zlib_dir = glob('src/c-blosc/internal-complibs/zlib*')[0]
+ zlib_dir = glob('src/c-blosc/internal-complibs/zlib*')[0]
- config = dict(
- sources=glob(f'{zlib_dir}/*.c'),
- include_dirs=[zlib_dir],
- cflags=cflags,
- )
+ config = dict(
+ sources=glob(f'{zlib_dir}/*.c'),
+ include_dirs=[zlib_dir],
+ cflags=cflags,
+ )
if field is None:
- return 'zlib', config
+ return 'z', config
return config[field]
def get_zstd_clib(field=None):
- """zstd static lib build config"""
- cflags = ['-O3', '-ffast-math', '-std=gnu99']
- cflags += ['/Ox', '/fp:fast']
+ """zstd static lib build config"""
+ if os.environ.get('HDF5PLUGIN_SYSTEM_ZSTD', None):
+ if field == 'extra_objects':
+ return []
+ config = dict(
+ sources=[],
+ include_dirs=[subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'libzstd']
+ )],
+ cflags=[],
+ )
+ else:
+ cflags = ['-O3', '-ffast-math', '-std=gnu99']
+ cflags += ['/Ox', '/fp:fast']
- zstd_dir = glob('src/c-blosc2/internal-complibs/zstd*')[0]
+ zstd_dir = glob('src/c-blosc2/internal-complibs/zstd*')[0]
- config = dict(
- sources=glob(f'{zstd_dir}/*/*.c'),
- include_dirs=[zstd_dir, f'{zstd_dir}/common'],
- macros=[] if BuildConfig.USE_BMI2 else [('ZSTD_DISABLE_ASM', 1)],
- cflags=cflags,
- )
+ if field == 'extra_objects':
+ return glob(f'{zstd_dir}/*/*.S') if BuildConfig.USE_BMI2 else []
+
+ config = dict(
+ sources=glob(f'{zstd_dir}/*/*.c'),
+ include_dirs=[zstd_dir, f'{zstd_dir}/common'],
+ cflags=cflags,
+ )
+
+ config['macros'] = [] if BuildConfig.USE_BMI2 else [('ZSTD_DISABLE_ASM', 1)]
if field is None:
return 'zstd', config
- if field == 'extra_objects':
- return glob(f'{zstd_dir}/*/*.S') if BuildConfig.USE_BMI2 else []
return config[field]
@@ -823,16 +845,25 @@
Plugin from https://github.com/Blosc/hdf5-blosc
c-blosc from https://github.com/Blosc/c-blosc
"""
- blosc_dir = 'src/c-blosc/blosc'
hdf5_blosc_dir = 'src/hdf5-blosc/src'
- # blosc sources
- sources = glob(f'{blosc_dir}/*.c')
- include_dirs = ['src/c-blosc', blosc_dir]
+ if os.environ.get('HDF5PLUGIN_SYSTEM_BLOSC', None):
+ sources = []
+ include_dirs = [subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'blosc']
+ )]
+ libraries = [l.strip()[2:] for l in subprocess.check_output(
+ ["pkg-config", '--libs', 'blosc']
+ ).decode().strip().split(" ")]
+ else:
+ # blosc sources
+ blosc_dir = 'src/c-blosc/blosc'
+ sources = glob(f'{blosc_dir}/*.c')
+ include_dirs = ['src/c-blosc', blosc_dir]
+ libraries = []
define_macros = []
extra_link_args = []
- libraries = []
-
+
# compression libs
# lz4
include_dirs += get_lz4_clib('include_dirs')
@@ -878,7 +909,7 @@
)
-PLUGIN_LIB_DEPENDENCIES['blosc'] = 'snappy', 'lz4', 'zlib', 'zstd'
+PLUGIN_LIB_DEPENDENCIES['blosc'] = 'snappy', 'lz4', 'z', 'zstd'
def get_blosc2_plugin():
@@ -887,40 +918,45 @@
Source from PyTables and c-blosc2
"""
hdf5_blosc2_dir = 'src/PyTables/hdf5-blosc2/src'
- blosc2_dir = 'src/c-blosc2'
- plugins_dir = f'{blosc2_dir}/plugins'
- # blosc sources
- sources = glob(f'{blosc2_dir}/blosc/*.c')
- sources += [ # Add embedded codecs, filters and tuners
- src_file
- for src_file in glob(f'{plugins_dir}/*.c') + glob(f'{plugins_dir}/*/*.c') + glob(f'{plugins_dir}/*/*/*.c')
- if not os.path.basename(src_file).startswith("test")
- ]
- sources += glob(f'{plugins_dir}/codecs/zfp/src/*.c') # Add ZFP embedded sources
+ if os.environ.get('HDF5PLUGIN_SYSTEM_BLOSC2', None):
+ sources = []
+ include_dirs = [subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'blosc2']
+ )]
+ libraries = [l.strip()[2:] for l in subprocess.check_output(
+ ["pkg-config", '--libs', 'blosc2']
+ ).decode().strip().split(" ")]
+ else:
+ blosc2_dir = 'src/c-blosc2'
+ plugins_dir = f'{blosc2_dir}/plugins'
- include_dirs = [
- blosc2_dir,
- f'{blosc2_dir}/blosc',
- f'{blosc2_dir}/include',
- f'{blosc2_dir}/plugins/codecs/zfp/include',
- ]
+ # blosc sources
+ sources = glob(f'{blosc2_dir}/blosc/*.c')
+ sources += [ # Add embedded codecs, filters and tuners
+ src_file
+ for src_file in glob(f'{plugins_dir}/*.c') + glob(f'{plugins_dir}/*/*.c') + glob(f'{plugins_dir}/*/*/*.c')
+ if not os.path.basename(src_file).startswith("test")
+ ]
+ sources += glob(f'{plugins_dir}/codecs/zfp/src/*.c') # Add ZFP embedded sources
+
+ include_dirs = [
+ blosc2_dir,
+ f'{blosc2_dir}/blosc',
+ f'{blosc2_dir}/include',
+ f'{blosc2_dir}/plugins/codecs/zfp/include',
+ ]
+ libraries = []
+
define_macros = [
('HAVE_PLUGINS', 1),
- ('SHUFFLE_AVX512_ENABLED', 1),
- ('SHUFFLE_NEON_ENABLED', 1),
+ ('SHUFFLE_AVX512_ENABLED', 0),
+ ('SHUFFLE_NEON_ENABLED', 0),
]
+
extra_compile_args = []
extra_link_args = []
- libraries = []
-
- if platform.machine() == 'ppc64le':
- define_macros.append(('SHUFFLE_ALTIVEC_ENABLED', 1))
- define_macros.append(('NO_WARN_X86_INTRINSICS', None))
- if HostConfig.ARCH == 'ARM_8':
- extra_compile_args += ['-flax-vector-conversions']
- if HostConfig.ARCH == 'ARM_7':
- extra_compile_args += ['-mfpu=neon', '-flax-vector-conversions']
+
# compression libs
# lz4
@@ -942,10 +978,6 @@
include_dirs += get_zstd_clib('include_dirs')
define_macros.append(('HAVE_ZSTD', 1))
- extra_compile_args += ['-O3', '-std=gnu99']
- extra_compile_args += ['/Ox']
- extra_compile_args += ['-pthread']
- extra_link_args += ['-pthread']
return HDF5PluginExtension(
"hdf5plugin.plugins.libh5blosc2",
@@ -962,7 +994,7 @@
)
-PLUGIN_LIB_DEPENDENCIES['blosc2'] = 'lz4', 'zlib', 'zstd'
+PLUGIN_LIB_DEPENDENCIES['blosc2'] = 'lz4', 'z', 'zstd'
def get_zstandard_plugin():
@@ -1044,31 +1076,47 @@
def get_bzip2_plugin():
"""BZip2 plugin build config"""
- bzip2_dir = "src/bzip2"
+ if os.environ.get('HDF5PLUGIN_SYSTEM_BZIP2', None):
+ bzip2_extra_compile_args = []
+ sources = []
+ include_dirs = [subprocess.check_output(
+ ["pkg-config", '--variable=includedir', 'bzip2']
+ )]
+ libraries = [l.strip()[2:] for l in subprocess.check_output(
+ ["pkg-config", '--libs', 'bzip2']
+ ).decode().strip().split(" ")]
+
+ else:
+ bzip2_dir = "src/bzip2"
+
+ bzip2_extra_compile_args = [
+ "-Wall",
+ "-Winline",
+ "-O2",
+ "-g",
+ "-D_FILE_OFFSET_BITS=64"
+ ]
- bzip2_extra_compile_args = [
- "-Wall",
- "-Winline",
- "-O2",
- "-g",
- "-D_FILE_OFFSET_BITS=64"
- ]
+ sources = prefix(bzip2_dir, [
+ "blocksort.c",
+ "huffman.c",
+ "crctable.c",
+ "randtable.c",
+ "compress.c",
+ "decompress.c",
+ "bzlib.c",
+ ])
+ include_dirs = [bzip2_dir]
+ libraries=[]
- sources = ['src/PyTables/src/H5Zbzip2.c', 'src/H5Zbzip2_plugin.c']
- sources += prefix(bzip2_dir, [
- "blocksort.c",
- "huffman.c",
- "crctable.c",
- "randtable.c",
- "compress.c",
- "decompress.c",
- "bzlib.c",
- ])
+ include_dirs += ['src/PyTables/src/']
+ sources += ['src/PyTables/src/H5Zbzip2.c', 'src/H5Zbzip2_plugin.c']
return HDF5PluginExtension(
"hdf5plugin.plugins.libh5bzip2",
sources=sources,
- include_dirs=['src/PyTables/src/', bzip2_dir],
+ include_dirs=include_dirs,
+ libraries=libraries,
define_macros=[('HAVE_BZ2_LIB', 1)],
extra_compile_args=bzip2_extra_compile_args,
)
@@ -1142,7 +1190,7 @@
)
-PLUGIN_LIB_DEPENDENCIES['sz'] = ('zlib', 'zstd')
+PLUGIN_LIB_DEPENDENCIES['sz'] = ('z', 'zstd')
def get_sz3_plugin():
@@ -1190,13 +1238,14 @@
if 'all' in stripped_filters:
return [], []
- # Filter out library that won't be used because of stripped filters
+ # Filter out library that won't be used because of stripped filters or is usable from system
lib_names = set(
itertools.chain.from_iterable(
lib_names for filter_name, lib_names in dependencies.items()
- if filter_name not in stripped_filters
+ if (filter_name not in stripped_filters
+ and not os.environ.get(f"HDF5PLUGIN_SYSTEM_{filter_name.upper()}", None))
)
- )
+ )
libraries = [
lib for lib in libraries if lib[0] in lib_names