mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-03 18:16:22 +01:00
get HDF5 compilation flags from pythonic pkgconfig
This commit is contained in:
parent
c3cc76c492
commit
1b05157316
@ -1,6 +1,7 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = [
|
requires = [
|
||||||
"setuptools>=42",
|
"setuptools>=42",
|
||||||
"wheel"
|
"wheel",
|
||||||
|
"pkgconfig"
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
@ -14,10 +14,37 @@ c_files = ['trexio.c', 'trexio_hdf5.c', 'trexio_text.c', 'pytrexio_wrap.c']
|
|||||||
with open("README.md", "r") as fh:
|
with open("README.md", "r") as fh:
|
||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
|
|
||||||
h5_ldflags = str(os.environ.get("H5_LDFLAGS", None ))
|
# =========================== Start of the HDF5 block =========================== #
|
||||||
h5_cflags_withI = str(os.environ.get("H5_CFLAGS", None ))
|
# The block below is needed to derive additional flags related to the HDF5 library,
|
||||||
h5_cflags = h5_cflags_withI.replace("-I","")
|
# which is required to build pytrexio extension module during the setup.py execution
|
||||||
|
|
||||||
|
h5_ldflags_withl = os.environ.get("H5_LDFLAGS", None)
|
||||||
|
h5_cflags_withI = os.environ.get("H5_CFLAGS", None)
|
||||||
|
|
||||||
|
h5_ldflags_isUndefined = h5_ldflags_withl is None or h5_ldflags_withl==""
|
||||||
|
h5_cflags_isUndefined = h5_cflags_withI is None or h5_cflags_withI==""
|
||||||
|
|
||||||
|
if h5_ldflags_isUndefined or h5_cflags_isUndefined:
|
||||||
|
|
||||||
|
try:
|
||||||
|
import pkgconfig as pk
|
||||||
|
except ImportError:
|
||||||
|
raise Exception("pkgconfig Python package has not been found")
|
||||||
|
|
||||||
|
try:
|
||||||
|
assert pk.exists('hdf5')
|
||||||
|
except AssertionError:
|
||||||
|
raise Exception("pkg-config could not locate HDF5")
|
||||||
|
|
||||||
|
h5_cflags_withI = pk.cflags('hdf5')
|
||||||
|
h5_ldflags_withl = pk.libs('hdf5')
|
||||||
|
|
||||||
|
h5_cflags = h5_cflags_withI.replace("-I","").split(" ")[0]
|
||||||
|
h5_ldflags = h5_ldflags_withl.split(" ")[0]
|
||||||
|
|
||||||
|
# ============================ End of the HDF5 block ============================ #
|
||||||
|
|
||||||
|
# Define pytrexio extension module based on TREXIO source codes + SWIG-generated wrapper
|
||||||
pytrexio_module = Extension('pytrexio._pytrexio',
|
pytrexio_module = Extension('pytrexio._pytrexio',
|
||||||
sources = [os.path.join(srcpath, code) for code in c_files],
|
sources = [os.path.join(srcpath, code) for code in c_files],
|
||||||
include_dirs = [h5_cflags, srcpath],
|
include_dirs = [h5_cflags, srcpath],
|
||||||
|
Loading…
Reference in New Issue
Block a user