mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-08 20:33:36 +01:00
more portable build of the Python extension module with HDF5 paths propagated from configure script
This commit is contained in:
parent
aee68dd619
commit
09823dd6a0
11
Makefile.am
11
Makefile.am
@ -157,6 +157,10 @@ $(HTML_FILES): docs/index.html
|
||||
|
||||
# =============== DEVELOPER MODE =============== #
|
||||
|
||||
SWIG = @SWIG@
|
||||
HDF5_LDFLAGS = @HDF5_LDFLAGS@
|
||||
HDF5_CFLAGS = @HDF5_CFLAGS@
|
||||
|
||||
if TREXIO_DEVEL
|
||||
|
||||
CLEANFILES += $(SOURCES) $(trexio_f) $(trexio_h)
|
||||
@ -183,7 +187,6 @@ cppcheck.out: $(trexio_h)
|
||||
--language=c --std=c99 -rp --platform=unix64 \
|
||||
-I../include *.c *.h 2>../$@
|
||||
|
||||
|
||||
setup_py = $(srcdir)/python/setup.py
|
||||
setup_cfg = $(srcdir)/python/setup.cfg
|
||||
pytrexio_py = $(srcdir)/python/pytrexio/pytrexio.py
|
||||
@ -199,7 +202,8 @@ python-test: $(TEST_PY)
|
||||
$(RM) -r -- __pycache__
|
||||
|
||||
python-install: $(pytrexio_py) $(setup_py) $(setup_cfg)
|
||||
cd python && ./install_pytrexio.sh
|
||||
cd python && \
|
||||
./install_pytrexio.sh $(HDF5_LDFLAGS) $(HDF5_CFLAGS)
|
||||
|
||||
$(pytrexio_py): $(pytrexio_c)
|
||||
cd tools && ./prepare_python.sh
|
||||
@ -208,7 +212,8 @@ $(pytrexio_py): $(pytrexio_c)
|
||||
# [?] swig -python -threads pytrexio.i ----> Add thread support for all the interface
|
||||
$(pytrexio_c): $(ORG_FILES) $(trexio_h) $(pytrexio_i) $(numpy_i)
|
||||
cp $(trexio_h) src/
|
||||
cd src/ && swig -python -py3 -o pytrexio_wrap.c pytrexio.i
|
||||
cd src/ && \
|
||||
$(SWIG) -python -py3 -o pytrexio_wrap.c pytrexio.i
|
||||
$(RM) -- src/trexio.h
|
||||
|
||||
$(numpy_i):
|
||||
|
@ -3,6 +3,9 @@
|
||||
set -x
|
||||
set -e
|
||||
|
||||
H5_LDFLAGS_LOCAL=$1
|
||||
H5_CFLAGS_LOCAL=$2
|
||||
|
||||
# This script should update the version of the Python package
|
||||
#source version.py
|
||||
|
||||
@ -11,7 +14,7 @@ python3 -m pip install --upgrade setuptools wheel twine
|
||||
|
||||
# Create build directory and compile extension files (*.c)
|
||||
# --no-user-cfg disables custom .cfg files of the user machine, so that only setup.cfg is used
|
||||
python3 -s setup.py --no-user-cfg build
|
||||
H5_LDFLAGS=${H5_LDFLAGS_LOCAL} H5_CFLAGS=${H5_CFLAGS_LOCAL} python3 -s setup.py --no-user-cfg build
|
||||
|
||||
# Local inplace build of the .so module with SWIG-produced pytrexio_wrap.c (from the SWIG documentation)
|
||||
#python3 setup.py build_ext --inplace --swig-opts="-modern"
|
||||
|
@ -14,13 +14,16 @@ c_files = ['trexio.c', 'trexio_hdf5.c', 'trexio_text.c', 'pytrexio_wrap.c']
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
h5_ldflags = str(os.environ.get("H5_LDFLAGS", None ))
|
||||
h5_cflags_withI = str(os.environ.get("H5_CFLAGS", None ))
|
||||
h5_cflags = h5_cflags_withI.replace("-I","")
|
||||
|
||||
pytrexio_module = Extension('pytrexio._pytrexio',
|
||||
sources = [os.path.join(srcpath, code) for code in c_files],
|
||||
include_dirs = ['/usr/include/hdf5/serial', srcpath],
|
||||
include_dirs = [h5_cflags, srcpath],
|
||||
libraries = ['hdf5', 'hdf5_hl'],
|
||||
extra_compile_args = ['-Wno-discarded-qualifiers'],
|
||||
extra_link_args = ['-L/usr/lib/x86_64-linux-gnu/hdf5/serial']
|
||||
extra_link_args = [h5_ldflags]
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user