Salome HOME
fix a bug with 'test -n' option
[tools/install.git] / config_files / Python-2.2.1.sh
index 9a3a86eb8ae8bd6334237dd573a61d9621ab2263..2ddc754f8fb4cd2d3fa6c4279659cd12dbb97e6d 100755 (executable)
@@ -6,9 +6,12 @@ if [ -z "$PYTHONHOME"  ]; then
    return 1
 fi
 isPython=`which python 2>/dev/null`
-if [ -n isPython ]; then
+if [ -n "$isPython" ]; then
+  # version number is calculated as: <major>*10000+<minor>*100+<release>
+  # e.g. for Python 2.2.1 it is equal to 20201
   ver=`python -V 2>&1`
-  if [ "$ver" = "Python 2.2.1" ] ;  then 
+  ver=`echo $ver | awk '{print $2}' | awk -F. '{v1=0;v2=0;v3=0;if(NF>0)v1=$1;if(NF>1)v2=$2;if(NF>2)v3=$3;print v1*10000+v2*100+v3}'`
+  if [ $ver -eq 20201 ] ;  then 
     return 0
   fi
 fi
@@ -20,10 +23,10 @@ print_env()
 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
 #$DELIM ${PRODUCT_TYPE} $DELIM
 export PYTHONHOME=\${INSTALL_ROOT}/${PRODUCT}
-export PYTHON_INCLUDE=\${PYTHONHOME}/include/python2.2
-export PYTHONPATH=\${PYTHONHOME}/lib/python2.2:\${PYTHONPATH}
 export PATH=\${PYTHONHOME}/bin:\${PATH}
-export LD_LIBRARY_PATH=\${PYTHONHOME}/lib/python2.2:\${LD_LIBRARY_PATH}
+export PYTHON_VERSION=\`python -c "import sys; print sys.version[:3]"\`
+export PYTHON_INCLUDE=\${PYTHONHOME}/include/python\${PYTHON_VERSION}
+export PYTHONPATH=\${PYTHONHOME}/lib/python\${PYTHON_VERSION}:\${PYTHONPATH}
 ##
 EOF
 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
@@ -38,18 +41,39 @@ if [ -z "${pythonhome}" ] ; then
 fi
 if [ -n "${pythonhome}" ] ; then
     pythonhome=`cd ${pythonhome}/..; pwd`
-    if [ "`${pythonhome}/bin/python -V 2>&1`" == "Python 2.2.1" ] ; then 
-       tmp="\${PYTHONHOME}/lib/python2.2 ${pythonhome}/lib/python2.2 \${PYTHONPATH} ${PYTHONPATH}";  
+    # get version number: <major>, <minor> and <release>
+    # <major> and <minor> numbers are checked strickly, but <release> number can be larger than required one
+    # version number is calculated as: <major>*10000+<minor>*100+<release>
+    # e.g. for Python 2.2.1 it is equal to 20201
+    ver=`python -V 2>&1`
+    maj_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>0) print $1; else print 0}'`
+    min_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>1) print $2; else print 0}'`
+    rel_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>2) print $3; else print 0}'`
+    let ver=$maj_ver*10000+$min_ver*100+$rel_ver
+    if [ $ver -ge 20201 ] ;  then 
+#   if [ "`${pythonhome}/bin/python -V 2>&1`" == "Python 2.2.1" ] ; then 
+       tmp="\${PYTHONHOME}/bin ${pythonhome}/bin \${PATH} ${PATH}";  
+       path=`sort_path ${tmp}`
+       tmp="\${PYTHONHOME}/lib/python\${PYTHON_VERSION} ${pythonhome}/lib/python${maj_ver}.${min_ver} \${PYTHONPATH} ${PYTHONPATH}";  
        pythonpath=`sort_path ${tmp}`
        cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
 #$DELIM ${PRODUCT_TYPE} $DELIM
 export PYTHONHOME=${pythonhome}
-export PYTHON_INCLUDE=\${PYTHONHOME}/include/python2.2
+export PATH=${path}
+export PYTHON_VERSION=\`python -c "import sys; print sys.version[:3]"\`
+export PYTHON_INCLUDE=\${PYTHONHOME}/include/python\${PYTHON_VERSION}
 export PYTHONPATH=${pythonpath}
 ##
 EOF
        make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
-       return 0
+#######       THIS COULD BE USED FOR STRICT COMPARISON  ##############################
+#      if [ $maj_ver -eq 2 ] && [ $min_ver -eq 2 ] && [ $rel_ver -eq 1 ] ;  then 
+######################################################################################
+       if [ $maj_ver -eq 2 ] && [ $min_ver -eq 2 ] && [ $rel_ver -ge 1 ] ;  then 
+           return 0
+       else
+           return 2
+       fi
     fi
 fi
 return 1
@@ -75,6 +99,9 @@ check_job ${PRODUCT_DIR}/CONFIGURE.LOG \
 # vsr: not compiled on RedHat8.0 without libstdc++.so
 sed -e 's%LIBS=                -ldl  -lpthread -lutil%LIBS=            -ldl  -lpthread -lutil -lstdc++%g' Makefile > Makefile_new
 mv -f Makefile_new Makefile
+# vsr: socket module is not compiled on RedHat9 because of absent KERBEROS include/libs flags
+sed -e "s%\[('USE_SSL',1)\]%\[('USE_SSL',1),('OPENSSL_NO_KRB5',None)\]%g" setup.py > setup_new.py
+mv -f setup_new.py setup.py
 GCC=`which gcc`
 cat >> ${PRODUCT_DIR}/MAKE.LOG <<EOF
 used gcc=$GCC