Salome HOME
merge from master
[tools/sat_salome.git] / products / compil_scripts / Python-3.9.sh
1 #!/bin/bash
2
3 echo "##########################################################################"
4 echo "Python" $VERSION
5 echo "##########################################################################"
6
7 if [ ${#VERSION} -lt 5 ]
8 then
9     echo "ERROR : VERSION argument of Python compilation script has not the expected x.y.z format"
10     exit 1
11 fi
12 PYTHON_VERSION="${VERSION:0:3}"
13
14 # --enable-shared   : enable building shared python library
15 # --with-threads    : enable thread support
16 # --without-pymalloc: disable specialized mallocs
17 # --with-ensurepip  : installation using bundled pip
18 # --enable-optimizations:  recommandé et utilisé par Nijni -> mais trop long!
19 CONFIGURE_ARGUMENTS="--enable-shared --with-threads --with-ensurepip=install --with-ssl --enable-loadable-sqlite-extensions --with-pymalloc"
20
21 echo
22 echo   "*** configure --prefix=$PRODUCT_INSTALL $CONFIGURE_ARGUMENTS"
23 $SOURCE_DIR/configure --prefix=$PRODUCT_INSTALL $CONFIGURE_ARGUMENTS
24 if [ $? -ne 0 ]
25 then
26     echo "ERROR on configure"
27     exit 1
28 fi
29
30 echo
31 echo "*** make" $MAKE_OPTIONS
32 make $MAKE_OPTIONS
33 if [ $? -ne 0 ]
34 then
35     echo "ERROR on make"
36     exit 2
37 fi
38
39 echo
40 echo "*** make install"
41 make install
42 if [ $? -ne 0 ]
43 then
44     echo "ERROR on make install"
45     exit 3
46 fi
47
48 cd ${PRODUCT_INSTALL}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}*
49
50 if [ ! -e libpython${PYTHON_VERSION}.so ]
51 then
52     echo
53     echo "*** create missing link"
54     ln -sf ../../libpython${PYTHON_VERSION}.so .
55     if [ $? -ne 0 ]
56     then
57         echo "ERROR when creating missing link"
58         # no error here
59     fi
60 fi
61 cd ${PRODUCT_INSTALL}/bin
62 ln -s python3 python
63 ln -s pip3 pip
64 #
65 if [ "${SAT_ENABLE_PYTHON_PYMALLOC}" == "1" ]; then
66     cd ${PRODUCT_INSTALL}/include
67     if [ ! -d python3.9 ]; then
68         ln -s python3.9m python3.9
69     fi
70 fi
71
72 # fix the path... 
73 L="2to3  2to3-3.9 easy_install-3.9 idle3 idle3.9 pip3 pip3.9 pydoc3 pydoc3.9 pyvenv pyvenv-3.9"
74 cd ${PRODUCT_INSTALL}/bin
75 for f in  $L; do
76     awk '$0 = NR==1 ? replace : $0' replace="#!/usr/bin/env python3" $f > $f.t && mv $f.t $f && chmod 755 $f
77 done
78
79 echo
80 echo "########## END"
81