Skip to content

Commit

Permalink
Allow building with system lzf library via setting H5PY_SYSTEM_LZF=1
Browse files Browse the repository at this point in the history
  • Loading branch information
opoplawski committed Oct 10, 2020
1 parent f1d1c72 commit da96e2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lzf/lzf_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
21 changes: 17 additions & 4 deletions setup_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ def localpath(*args):
'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')],
Expand All @@ -46,6 +42,22 @@ def localpath(*args):
]
}

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([
Expand Down Expand Up @@ -98,6 +110,7 @@ def _make_extensions(config):

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]
Expand Down

0 comments on commit da96e2b

Please sign in to comment.