h5py/h5py-system-lzf.patch

70 lines
2.1 KiB
Diff

diff --git a/lzf/lzf_filter.c b/lzf/lzf_filter.c
index 951b1e4c..67c2b95a 100644
--- a/lzf/lzf_filter.c
+++ b/lzf/lzf_filter.c
@@ -26,7 +26,7 @@
#include <stdio.h>
#include <errno.h>
#include "hdf5.h"
-#include "lzf/lzf.h"
+#include "lzf.h"
#include "lzf_filter.h"
/* Our own versions of H5Epush_sim, as it changed in 1.8 */
diff --git a/news/system_lzf.rst b/news/system_lzf.rst
new file mode 100644
index 00000000..3ec5f6ea
--- /dev/null
+++ b/news/system_lzf.rst
@@ -0,0 +1,4 @@
+Building h5py
+-------------
+
+* Allow building against system lzf library by setting H5PY_SYSTEM_LZF=1
diff --git a/setup_build.py b/setup_build.py
index 03c47fa0..3c7c7adb 100644
--- a/setup_build.py
+++ b/setup_build.py
@@ -33,10 +33,6 @@ MODULES = ['defs', '_errors', '_objects', '_proxy', 'h5fd', 'h5z',
'h5ds', 'h5ac',
'h5pl']
-EXTRA_SRC = {'h5z': [ localpath("lzf/lzf_filter.c"),
- localpath("lzf/lzf/lzf_c.c"),
- localpath("lzf/lzf/lzf_d.c")]}
-
COMPILER_SETTINGS = {
'libraries' : ['hdf5', 'hdf5_hl'],
'include_dirs' : [localpath('lzf')],
@@ -46,6 +42,22 @@ COMPILER_SETTINGS = {
]
}
+EXTRA_SRC = {'h5z': [ localpath("lzf/lzf_filter.c") ]}
+
+# Set the environment variable H5PY_SYSTEM_LZF=1 if we want to
+# use the system lzf library
+if os.environ.get('H5PY_SYSTEM_LZF', '0') == '1':
+ EXTRA_LIBRARIES = {
+ 'h5z': [ 'lzf' ]
+ }
+else:
+ COMPILER_SETTINGS['include_dirs'] += [localpath('lzf/lzf')]
+
+ EXTRA_SRC['h5z'] += [localpath("lzf/lzf/lzf_c.c"),
+ localpath("lzf/lzf/lzf_d.c")]
+
+ EXTRA_LIBRARIES = {}
+
if sys.platform.startswith('win'):
COMPILER_SETTINGS['include_dirs'].append(localpath('windows'))
COMPILER_SETTINGS['define_macros'].extend([
@@ -98,6 +110,7 @@ class h5py_build_ext(build_ext):
def make_extension(module):
sources = [localpath('h5py', module + '.pyx')] + EXTRA_SRC.get(module, [])
+ settings['libraries'] += EXTRA_LIBRARIES.get(module, [])
return Extension('h5py.' + module, sources, **settings)
return [make_extension(m) for m in MODULES]