Salome HOME
merge from master
[tools/sat_salome.git] / products / compil_scripts / Python-3.6.15.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 # spns #30153 :  pymalloc on demand
20 CONFIGURE_ARGUMENTS="--enable-shared --with-threads --with-ensurepip=install --with-ssl --enable-loadable-sqlite-extensions"
21 if [ "${SAT_ENABLE_PYTHON_PYMALLOC}" == "1" ]; then
22     CONFIGURE_ARGUMENTS+=" --with-pymalloc"
23 else
24     CONFIGURE_ARGUMENTS+=" --without-pymalloc"
25 fi
26
27 echo
28 echo   "*** configure --prefix=$PRODUCT_INSTALL $CONFIGURE_ARGUMENTS"
29 $SOURCE_DIR/configure --prefix=$PRODUCT_INSTALL $CONFIGURE_ARGUMENTS
30 if [ $? -ne 0 ]
31 then
32     echo "ERROR on configure"
33     exit 1
34 fi
35
36 echo
37 echo "*** make" $MAKE_OPTIONS
38 make $MAKE_OPTIONS
39 if [ $? -ne 0 ]
40 then
41     echo "ERROR on make"
42     exit 2
43 fi
44
45 echo
46 echo "*** make install"
47 make install
48 if [ $? -ne 0 ]
49 then
50     echo "ERROR on make install"
51     exit 3
52 fi
53
54 cd ${PRODUCT_INSTALL}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}*
55
56 if [ ! -e libpython${PYTHON_VERSION}.so ]
57 then
58     echo
59     echo "*** create missing link"
60     ln -sf ../../libpython${PYTHON_VERSION}.so .
61     if [ $? -ne 0 ]
62     then
63         echo "ERROR when creating missing link"
64         # no error here
65     fi
66 fi
67 cd ${PRODUCT_INSTALL}/bin
68 ln -s python3 python
69 ln -s pip3 pip
70 #
71 if [ "${SAT_ENABLE_PYTHON_PYMALLOC}" == "1" ]; then
72     cd ${PRODUCT_INSTALL}/include
73     if [ ! -d python3.6 ]; then
74         ln -s python3.6m python3.6
75     fi
76 fi
77
78 # fix the path... 
79 L="2to3  2to3-3.6 easy_install-3.6 idle3 idle3.6 pip3 pip3.6 pydoc3 pydoc3.6 pyvenv pyvenv-3.6"
80 cd ${PRODUCT_INSTALL}/bin
81 for f in  $L; do
82     awk '$0 = NR==1 ? replace : $0' replace="#!/usr/bin/env python3" $f > $f.t && mv $f.t $f && chmod 755 $f
83 done
84
85 echo
86 echo "########## END"
87