]> SALOME platform Git repositories - tools/sat_salome.git/commitdiff
Salome HOME
align Numpy compilation approach
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 30 Jan 2023 15:03:46 +0000 (16:03 +0100)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 30 Jan 2023 15:03:52 +0000 (16:03 +0100)
products/compil_scripts/numpy-1.15.1.sh
products/compil_scripts/numpy.sh

index f70e0b0b44c7dfd58188a631c531ea0ad47fbfb0..05e370a7b81c86a393bec085fcbc3bf34761d1a2 100755 (executable)
@@ -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"
 
index eb9308867f03aa6a3b12b255fc828d28f57d99fa..05e370a7b81c86a393bec085fcbc3bf34761d1a2 100755 (executable)
@@ -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"