From 0c9d4898a9a7ac1ea4f5732e7800fd5e18788a0f Mon Sep 17 00:00:00 2001 From: Nabil Ghodbane Date: Mon, 30 Jan 2023 16:03:46 +0100 Subject: [PATCH] align Numpy compilation approach --- products/compil_scripts/numpy-1.15.1.sh | 62 ++++++++++++-------- products/compil_scripts/numpy.sh | 75 ++++++++++++++----------- 2 files changed, 81 insertions(+), 56 deletions(-) diff --git a/products/compil_scripts/numpy-1.15.1.sh b/products/compil_scripts/numpy-1.15.1.sh index f70e0b0..05e370a 100755 --- a/products/compil_scripts/numpy-1.15.1.sh +++ b/products/compil_scripts/numpy-1.15.1.sh @@ -8,40 +8,58 @@ echo "########################################################################## mkdir -p $PRODUCT_INSTALL cd $SOURCE_DIR +rm -f site.cfg -## editer customize.py Pour LApack : using Atlas, Pour Blas : Using gsl -# OP 29/03/2018 We create a build configuration file to set -# information about lapack preprequisite -echo "#" > site.cfg -echo "# Build configuration for numpy" >> site.cfg -echo "#" >> site.cfg -echo >> site.cfg -echo "# Section ALL to set global information for lapack dependency" >> site.cfg -echo "[ALL]" >> site.cfg -echo "libraries = lapack,blas,cblas,lapacke,tmglib" >> site.cfg -echo "library_dirs = \$\{LAPACKHOME\}/lib" >> site.cfg -#echo "runtime_library_dirs = ${LAPACKHOME}/lib" >> site.cfg -echo "include_dirs = \$\{LAPACKHOME\}/include" >> site.cfg -#echo "extra_link_args = -lcblas" >> site.cfg -echo >> site.cfg +if [ "$SAT_lapack_IS_NATIVE" != "1" ]; then + echo "Lapack is embedded... Make numpy aware of it..." + echo "[ALL]" > site.cfg + echo "libraries = lapack,blas,cblas,lapacke,tmglib" >> site.cfg + echo "library_dirs = \$\{LAPACKHOME\}/lib" >> site.cfg + echo "include_dirs = \$\{LAPACKHOME\}/include" >> site.cfg +fi +export PYTHONPATH=$SOURCE_DIR:$PYTHONPATH NUMPY_INSTALL=${PRODUCT_INSTALL}/lib/python${PYTHON_VERSION}/site-packages mkdir -p ${NUMPY_INSTALL} PYTHONPATH=${NUMPY_INSTALL}:${PYTHONPATH} echo -echo "*** setup.py install" -python setup.py install --prefix=${PRODUCT_INSTALL} -if [ $? -ne 0 ] -then - echo "ERROR on setup install" +echo "*** setup.py build install" +$PYTHONBIN setup.py build install --prefix=${PRODUCT_INSTALL} --install-lib=${NUMPY_INSTALL} +if [ $? -ne 0 ]; then + echo "ERROR on setup build install" rm -f site.cfg - exit 2 + exit 1 +fi +# the embedded versioneer.py fails to retrieve the correct version - presumably because of missing .git information +# let's fix this once for all - prevents openturns from not building. +cd ${NUMPY_INSTALL} +if [ -f numpy/_version.py ]; then + echo "INFO: ensure that version is consistently set. In principle patches " + sed -i "s/0+unknown/$VERSION/g" numpy/_version.py +else + f=$(find . -type d -name "numpy-$VERSION-py${PYTHON_VERSION}-*x86_64.egg") + if [ $? -eq 0 ]; then + EGG_DIR=$(ls |grep numpy-$VERSION-py${PYTHON_VERSION} |grep x86_64.egg) + echo "INFO: Found $EGG_DIR" + if [ -d $EGG_DIR/numpy ]; then + ln -sf $EGG_DIR/numpy + sed -i "s/0+unknown/$VERSION/g" $EGG_DIR/numpy/_version.py + else + echo "WARNING: could not find $EGG_DIR/numpy" + fi + else + echo "WARNING: could not find egg directory with name: numpy-$VERSION-py${PYTHON_VERSION}-*-x86_64.egg" + fi fi -rm -f site.cfg +if [ -d ${PRODUCT_INSTALL}/local/bin ]; then + mv ${PRODUCT_INSTALL}/local/bin ${PRODUCT_INSTALL}/bin + rm -rf ${PRODUCT_INSTALL}/local +fi +rm -f site.cfg echo echo "########## END" diff --git a/products/compil_scripts/numpy.sh b/products/compil_scripts/numpy.sh index eb93088..05e370a 100755 --- a/products/compil_scripts/numpy.sh +++ b/products/compil_scripts/numpy.sh @@ -8,51 +8,58 @@ echo "########################################################################## mkdir -p $PRODUCT_INSTALL cd $SOURCE_DIR +rm -f site.cfg + +if [ "$SAT_lapack_IS_NATIVE" != "1" ]; then + echo "Lapack is embedded... Make numpy aware of it..." + echo "[ALL]" > site.cfg + echo "libraries = lapack,blas,cblas,lapacke,tmglib" >> site.cfg + echo "library_dirs = \$\{LAPACKHOME\}/lib" >> site.cfg + echo "include_dirs = \$\{LAPACKHOME\}/include" >> site.cfg +fi -## editer customize.py Pour LApack : using Atlas, Pour Blas : Using gsl -# OP 29/03/2018 We create a build configuration file to set -# information about lapack preprequisite -echo "#" > site.cfg -echo "# Build configuration for numpy" >> site.cfg -echo "#" >> site.cfg -echo >> site.cfg -echo "# Section ALL to set global information for lapack dependency" >> site.cfg -echo "[ALL]" >> site.cfg -echo "libraries = lapack,blas,cblas,lapacke,tmglib" >> site.cfg -echo "library_dirs = \$\{LAPACKHOME\}/lib" >> site.cfg -#echo "runtime_library_dirs = ${LAPACKHOME}/lib" >> site.cfg -echo "include_dirs = \$\{LAPACKHOME\}/include" >> site.cfg -#echo "extra_link_args = -lcblas" >> site.cfg -echo >> site.cfg - -#echo -#echo "*** setup.py build" -#python setup.py build -#if [ $? -ne 0 ] -#then -# echo "ERROR on setup build" -# rm -f site.cfg -# exit 1 -#fi +export PYTHONPATH=$SOURCE_DIR:$PYTHONPATH NUMPY_INSTALL=${PRODUCT_INSTALL}/lib/python${PYTHON_VERSION}/site-packages mkdir -p ${NUMPY_INSTALL} PYTHONPATH=${NUMPY_INSTALL}:${PYTHONPATH} echo -echo "*** setup.py install" -# OP TEST -#python setup.py install --prefix=${PRODUCT_INSTALL} -$PYTHONBIN setup.py install --prefix=${PRODUCT_INSTALL} -if [ $? -ne 0 ] -then - echo "ERROR on setup install" +echo "*** setup.py build install" +$PYTHONBIN setup.py build install --prefix=${PRODUCT_INSTALL} --install-lib=${NUMPY_INSTALL} +if [ $? -ne 0 ]; then + echo "ERROR on setup build install" rm -f site.cfg - exit 2 + exit 1 +fi +# the embedded versioneer.py fails to retrieve the correct version - presumably because of missing .git information +# let's fix this once for all - prevents openturns from not building. +cd ${NUMPY_INSTALL} +if [ -f numpy/_version.py ]; then + echo "INFO: ensure that version is consistently set. In principle patches " + sed -i "s/0+unknown/$VERSION/g" numpy/_version.py +else + f=$(find . -type d -name "numpy-$VERSION-py${PYTHON_VERSION}-*x86_64.egg") + if [ $? -eq 0 ]; then + EGG_DIR=$(ls |grep numpy-$VERSION-py${PYTHON_VERSION} |grep x86_64.egg) + echo "INFO: Found $EGG_DIR" + if [ -d $EGG_DIR/numpy ]; then + ln -sf $EGG_DIR/numpy + sed -i "s/0+unknown/$VERSION/g" $EGG_DIR/numpy/_version.py + else + echo "WARNING: could not find $EGG_DIR/numpy" + fi + else + echo "WARNING: could not find egg directory with name: numpy-$VERSION-py${PYTHON_VERSION}-*-x86_64.egg" + fi fi -rm -f site.cfg +if [ -d ${PRODUCT_INSTALL}/local/bin ]; then + mv ${PRODUCT_INSTALL}/local/bin ${PRODUCT_INSTALL}/bin + rm -rf ${PRODUCT_INSTALL}/local +fi +rm -f site.cfg echo echo "########## END" -- 2.39.2