2022-01-19 14:09:28 +01:00
|
|
|
#!/bin/bash
|
2021-08-05 16:55:34 +02:00
|
|
|
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
|
2021-09-10 13:36:51 +02:00
|
|
|
# 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
|
2021-09-12 12:27:08 +02:00
|
|
|
if [[ -z ${H5_LDFLAGS} ]] || [[ -z ${H5_CFLAGS} ]]; then
|
2023-06-02 15:14:29 +02:00
|
|
|
# If pkg-config fails, try to locate hdf5 using h5cc
|
|
|
|
which h5cc &> /dev/null && HAS_H5CC=1
|
|
|
|
pkg-config --libs hdf5
|
|
|
|
if [[ $? -ne 0 && $HAS_H5CC == "1" ]] ; then
|
2023-06-02 14:53:54 +02:00
|
|
|
HDF5_tmp_flags=$(h5cc -showconfig \
|
|
|
|
| grep 'FLAGS\|Extra libraries:' \
|
|
|
|
| awk -F: '{printf("%s "), $2}' )
|
|
|
|
echo $HDF5_tmp_flags
|
|
|
|
|
|
|
|
# Find the installation directory and append include/
|
|
|
|
HDF5_tmp_inst=$(h5cc -showconfig \
|
|
|
|
| grep 'Installation point:' \
|
|
|
|
| awk '{print $NF}' )
|
|
|
|
echo $HDF5_tmp_inst
|
|
|
|
|
|
|
|
# Add this to the CPPFLAGS
|
|
|
|
HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include"
|
|
|
|
|
|
|
|
HDF5_SHOW=$(h5cc -show)
|
|
|
|
|
|
|
|
# Now sort the flags out based upon their prefixes
|
|
|
|
for arg in $HDF5_SHOW $HDF5_tmp_flags ; do
|
|
|
|
case "$arg" in
|
|
|
|
-I*) echo $HDF5_CPPFLAGS | grep -e "$arg" 2>&1 >/dev/null \
|
|
|
|
|| HDF5_CPPFLAGS="$HDF5_CPPFLAGS $arg"
|
|
|
|
;;
|
|
|
|
-L*) echo $HDF5_LDFLAGS | grep -e "$arg" 2>&1 >/dev/null \
|
|
|
|
|| HDF5_LDFLAGS="$HDF5_LDFLAGS $arg"
|
|
|
|
;;
|
|
|
|
-l*) echo $HDF5_LIBS | grep -e "$arg" 2>&1 >/dev/null \
|
|
|
|
|| HDF5_LIBS="$HDF5_LIBS $arg"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
export H5_LDFLAGS="$HDF5_LDFLAGS"
|
|
|
|
export H5_CFLAGS="$HDF5_CPPFLAGS"
|
|
|
|
else
|
|
|
|
echo "Paths to the HDF5 installation are not provided. pkgconfig will try to detect them."
|
|
|
|
fi
|
2021-09-12 12:27:08 +02:00
|
|
|
else
|
|
|
|
echo "Using exported H5_LDFLAGS and H5_CFLAGS environment variables."
|
|
|
|
fi
|
2021-09-10 13:36:51 +02:00
|
|
|
else
|
|
|
|
export H5_LDFLAGS=${H5_LDFLAGS_LOCAL}
|
|
|
|
export H5_CFLAGS=${H5_CFLAGS_LOCAL}
|
|
|
|
fi
|
2021-08-05 16:55:34 +02:00
|
|
|
|
2024-06-16 19:13:59 +02:00
|
|
|
|
2021-08-05 16:55:34 +02:00
|
|
|
# Install/upgrade packages required for the installation
|
2024-06-16 19:13:59 +02:00
|
|
|
python3 -m pip install build
|
2021-09-07 17:32:23 +02:00
|
|
|
python3 -m pip install -r requirements.txt
|
2022-06-01 17:42:30 +02:00
|
|
|
python3 -m pip install pytest
|
2021-08-05 16:55:34 +02:00
|
|
|
|
2021-09-10 13:36:51 +02:00
|
|
|
# export NUMPY_INCLUDEDIR environment variable needed for the proper setup
|
2022-01-07 18:47:23 +01:00
|
|
|
#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
|
2021-09-10 13:36:51 +02:00
|
|
|
|
2021-08-05 16:55:34 +02:00
|
|
|
# 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
|
2022-01-19 14:09:28 +01:00
|
|
|
#python3 -s setup.py --no-user-cfg build
|
2021-08-05 16:55:34 +02:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2022-01-19 14:09:28 +01:00
|
|
|
# Create distributions:
|
2022-01-07 18:47:23 +01:00
|
|
|
|
|
|
|
# OLD WAY (DEPRECATED BY PYPA)
|
2021-08-05 16:55:34 +02:00
|
|
|
# 1) sdist produces .tar.gz with all files necessary for manual compilation;
|
|
|
|
# 2) bdist_whell produces .whl wheel distribution (see https://www.python.org/dev/peps/pep-0425/).
|
2022-01-07 18:47:23 +01:00
|
|
|
#python3 setup.py sdist bdist_wheel
|
|
|
|
|
|
|
|
# NEW WAY (USING BUILD PACKAGE OF PYPA)
|
|
|
|
python3 -m build --sdist --wheel --outdir dist/
|
2021-08-05 16:55:34 +02:00
|
|
|
|
|
|
|
# Install pytrexio in the current environment from the aforementioned wheel
|
2022-01-19 14:09:28 +01:00
|
|
|
python3 -m pip install dist/trexio-*.whl --force-reinstall
|
2021-08-18 12:46:16 +02:00
|
|
|
|
|
|
|
# Run the command below in the root directory to install the package in 'editable' (-e) mode without dependencies (--no-deps)
|
|
|
|
#python -m pip install -e . --no-deps
|
2021-08-05 16:55:34 +02:00
|
|
|
|
2021-09-09 17:29:17 +02:00
|
|
|
# Uninstall pytrexio: this only works from the pytrexio root directory
|
2021-08-18 12:46:16 +02:00
|
|
|
#python3 -m pip uninstall trexio
|
2021-08-05 16:55:34 +02:00
|
|
|
|
2021-10-01 10:48:13 +02:00
|
|
|
# Install twine to upload things on PyPI
|
|
|
|
#python3 -m pip install --upgrade twine
|
|
|
|
|
2021-08-05 16:55:34 +02:00
|
|
|
# Test the current release by uploading to TestPyPI sandbox
|
2021-08-18 12:46:16 +02:00
|
|
|
#python3 -m twine upload --repository testpypi dist/trexio-*.tar.gz
|
2021-08-05 16:55:34 +02:00
|
|
|
|
|
|
|
# Upload updated version of PyTREXIO to PyPI
|
2021-08-18 12:46:16 +02:00
|
|
|
#python3 -m twine upload dist/trexio-*.tar.gz
|
2021-08-05 16:55:34 +02:00
|
|
|
|
|
|
|
# Cleaning
|
2023-01-02 16:00:57 +01:00
|
|
|
rm -rf build dist trexio.egg-info
|
2021-08-05 16:55:34 +02:00
|
|
|
|
2021-09-09 17:29:17 +02:00
|
|
|
# Additional information related to the installation of the TREXIO Python API
|
|
|
|
|
2022-01-19 14:09:28 +01:00
|
|
|
#Removing MANIFEST.in leads to issues in the installation. In particular, the .c and .h source files do not get copied
|
|
|
|
#from the src/ directory into the tar.gz which is produced by setup sdist command.
|
2021-09-09 17:29:17 +02:00
|
|
|
#These source files are required to build the pytrexio.so extension module, which is needed for the Python API.
|