1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-07-22 10:47:43 +02:00

more portable setup of environment variables for install_pytrexio.sh

This commit is contained in:
q-posev 2021-09-10 13:36:51 +02:00
parent c63d420c7f
commit 39c7587b5e
2 changed files with 28 additions and 4 deletions

View File

@ -160,6 +160,7 @@ $(HTML_FILES): docs/index.html
SWIG = @SWIG@
HDF5_LDFLAGS = @HDF5_LDFLAGS@
HDF5_CFLAGS = @HDF5_CFLAGS@
HDF5_CPPFLAGS = @HDF5_CPPFLAGS@
if TREXIO_DEVEL
@ -203,7 +204,7 @@ python-test: $(TEST_PY)
python-install: $(pytrexio_py) $(setup_py) $(setup_cfg)
cd python && \
./install_pytrexio.sh $(HDF5_CFLAGS) $(HDF5_LDFLAGS)
./install_pytrexio.sh $(HDF5_CFLAGS) $(HDF5_CPPFLAGS) $(HDF5_LDFLAGS)
python-sdist: $(pytrexio_py) $(setup_py) $(setup_cfg)
cd python && \

View File

@ -3,17 +3,40 @@
set -x
set -e
H5_CFLAGS_LOCAL=$1
H5_LDFLAGS_LOCAL=$2
# the parser below is needed when ./configure outputs several HDF5-related flags, which are then provided as input arguments to this script
for arg in "$@"
do
if [[ $arg == "-L"* ]] && [[ $arg == *"hdf5"* ]]; then
H5_LDFLAGS_LOCAL=$arg
elif [[ $arg == "-I"* ]] && [[ $arg == *"hdf5"* ]]; then
H5_CFLAGS_LOCAL=$arg
fi
done
# check that both variables are set
if [[ -z ${H5_LDFLAGS_LOCAL} ]] || [[ -z ${H5_CFLAGS_LOCAL} ]]; then
echo "Paths to the HDF5 installation are not found. pkgconfig Python package will try to detect them."
else
# additional explicit export was needed on MacOS
export H5_LDFLAGS=${H5_LDFLAGS_LOCAL}
export H5_CFLAGS=${H5_CFLAGS_LOCAL}
fi
# Install/upgrade packages required for the installation
python3 -m pip install --upgrade setuptools wheel twine
python3 -m pip install -r requirements.txt
# export NUMPY_INCLUDEDIR environment variable needed for the proper setup
source tools/set_NUMPY_INCLUDEDIR.sh
if [[ -z ${NUMPY_INCLUDEDIR} ]] ; then
echo "NUMPY_INCLUDEDIR is not set. Check that numpy is installed (e.g. call pip freeze)."
exit 1
fi
# 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
H5_LDFLAGS=${H5_LDFLAGS_LOCAL} H5_CFLAGS=${H5_CFLAGS_LOCAL} python3 -s setup.py --no-user-cfg build
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"