]> SALOME platform Git repositories - tools/install.git/blob - config_files/Python-2.3.4.sh
Salome HOME
Remove HappyDoc dependencies
[tools/install.git] / config_files / Python-2.3.4.sh
1 #!/bin/sh
2
3 check_version()
4 {
5 if [ -z "$PYTHONHOME"  ]; then
6    return 1
7 fi
8 isPython=`which python 2>/dev/null`
9 if [ -n "$isPython" ]; then
10   # version number is calculated as: <major>*10000+<minor>*100+<release>
11   # e.g. for Python 2.3.4 it is equal to 20304
12   ver=`python -V 2>&1`
13   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}'`
14   if [ $ver -eq 20304 ] ;  then 
15     return 0
16   fi
17 fi
18 return 1 
19 }
20
21 print_env()
22 {
23 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
24 #$DELIM ${PRODUCT_TYPE} $DELIM
25 export PYTHONHOME=\${INSTALL_ROOT}/${PRODUCT}
26 export PATH=\${PYTHONHOME}/bin:\${PATH}
27 export LD_LIBRARY_PATH=\${PYTHONHOME}/lib:\${LD_LIBRARY_PATH}
28 export PYTHON_VERSION=\`python -c "import sys; print sys.version[:3]"\`
29 export PYTHON_INCLUDE=\${PYTHONHOME}/include/python\${PYTHON_VERSION}
30 export PYTHONPATH=\${PYTHONHOME}/lib/python\${PYTHON_VERSION}:\${PYTHONPATH}
31 ##
32 EOF
33 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
34 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
35 }
36
37 # looks for the native product and collects it's environment (used by make_env())
38 try_native(){
39 pythonhome="`find_in_path python ${PATH}`"
40 if [ -z "${pythonhome}" ] ; then
41     pythonhome="`find_in_path python /usr/bin`"
42 fi
43 if [ -n "${pythonhome}" ] ; then
44     pythonhome=`cd ${pythonhome}/..; pwd`
45     # get version number: <major>, <minor> and <release>
46     # <major> and <minor> numbers are checked strickly, but <release> number can be larger than required one
47     # version number is calculated as: <major>*10000+<minor>*100+<release>
48     # e.g. for Python 2.3.4 it is equal to 20304
49     ver=`python -V 2>&1`
50     maj_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>0) print $1; else print 0}'`
51     min_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>1) print $2; else print 0}'`
52     rel_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>2) print $3; else print 0}'`
53     let ver=$maj_ver*10000+$min_ver*100+$rel_ver
54     if [ $ver -ge 20304 ] ;  then 
55         tmp="\${PYTHONHOME}/bin ${pythonhome}/bin \${PATH} ${PATH}";  
56         path=`sort_path ${tmp}`
57         tmp="\${PYTHONHOME}/lib/python\${PYTHON_VERSION} ${pythonhome}/lib/python${maj_ver}.${min_ver} \${PYTHONPATH} ${PYTHONPATH}";  
58         pythonpath=`sort_path ${tmp}`
59         tmp="\${PYTHONHOME}/lib ${pythonhome}/lib \${LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}";  
60         ld_library_path=`sort_path ${tmp}`
61         cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
62 #$DELIM ${PRODUCT_TYPE} $DELIM
63 export PYTHONHOME=${pythonhome}
64 export PATH=${path}
65 export LD_LIBRARY_PATH=${ld_library_path}
66 export PYTHON_VERSION=\`python -c "import sys; print sys.version[:3]"\`
67 export PYTHON_INCLUDE=\${PYTHONHOME}/include/python\${PYTHON_VERSION}
68 export PYTHONPATH=${pythonpath}
69 ##
70 EOF
71         make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
72 #######       THIS COULD BE USED FOR STRICT COMPARISON  ##############################
73 #       if [ $maj_ver -eq 2 ] && [ $min_ver -eq 3 ] && [ $rel_ver -eq 4 ] ;  then 
74 ######################################################################################
75         if [ $maj_ver -eq 2 ] && [ $min_ver -eq 3 ] && [ $rel_ver -ge 4 ] ;  then 
76             return 0
77         else
78             return 2
79         fi
80     fi
81 fi
82 return 1
83 }
84
85 try_preinstalled(){
86 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
87 return $?
88 }
89
90 install_source()
91 {
92 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
93 source ${INSTALL_WORK}/$SHRC
94
95 makedir ${PRODUCT_DIR}
96
97 check_jb tar xfz ${SOURCE_DIR}/Python-2.3.4.tar.gz -C ${INSTALL_WORK}
98 cd ${PRODUCT_WORK}
99
100 check_job ${PRODUCT_DIR}/CONFIGURE.LOG \
101     ./configure --prefix=${PRODUCT_DIR} --with-threads --with-cxx=`which g++` --enable-shared
102 # vsr: force linking to libstdc++.so
103 sed -e 's%\(^LIBS=.*\)%\1 -lstdc++%g' Makefile > _Makefile
104 mv -f _Makefile Makefile
105 GCC=`which gcc`
106 cat >> ${PRODUCT_DIR}/MAKE.LOG <<EOF
107 used gcc=$GCC
108 EOF
109
110 check_job ${PRODUCT_DIR}/MAKE.LOG make 
111 check_job ${PRODUCT_DIR}/MAKINSTALL.LOG make install
112 (cd ${PRODUCT_DIR}/lib/python2.3/config; ln -fs ../../libpython2.3.so.1.0 libpython2.3.so)
113
114 cd ${PRODUCT_DIR}/bin
115 for sc in idle pydoc smtpd.py ; do
116     if [ -e $sc ] ; then
117         sed -e "s%#\!.*python%#\!/usr/bin/env python%" "$sc" > _"$sc"
118         mv -f _"$sc" "$sc"
119         chmod a+x "$sc"
120     fi
121 done
122
123 #du -sk ${PRODUCT_WORK} > ${PRODUCT_DIR}/size.log
124 cd ${PRODUCT_DIR}; rm -fr ${PRODUCT_WORK}
125 print_env
126 }
127
128 install_binary()
129 {
130 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
131 source ${INSTALL_WORK}/$SHRC
132
133 check_jb tar xfz ${SOURCE_DIR}/Python-2.3.4.tar.gz -C ${INSTALL_ROOT}
134
135 (cd ${PRODUCT_DIR}/lib/python2.3/config; ln -fs ../../libpython2.3.so.1.0 libpython2.3.so)
136
137 cd ${PRODUCT_DIR}/bin
138 for sc in idle pydoc smtpd.py ; do
139     if [ -e $sc ] ; then
140         sed -e "s%#\!.*python%#\!/usr/bin/env python%" "$sc" > _"$sc"
141         mv -f _"$sc" "$sc"
142         chmod a+x "$sc"
143     fi
144 done
145
146 print_env
147 }
148
149 export PROCEDURE=$1;
150 export INSTALL_WORK=$2;
151 export SOURCE_DIR=$3;
152 export INSTALL_ROOT=$4;
153 export PRODUCT_SEQUENCE=$5;
154 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="python" ; fi
155 export PRODUCT="Python-2.3.4"
156 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
157 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
158 source ./common.sh
159 ${PROCEDURE}