Ticket #7867: spkg-install

File spkg-install, 5.7 KB (added by drkirkby, 10 years ago)

Updated spkg-install to avoid clash with 7761

Line 
1#!/usr/bin/env bash
2###########################################
3## Python
4###########################################
5
6CUR=`pwd`
7
8if [ "$SAGE_LOCAL" = "" ]; then
9   echo "SAGE_LOCAL undefined ... exiting";
10   echo "Maybe run 'sage -sh'?"
11   exit 1
12fi
13
14# PATCH
15
16# Due to a python bug with Solaris
17# see http://bugs.python.org/issue1759169
18# it is necessary to apply a patch to configure.in
19# then run autoconf. This not only generates a
20# new 'configure' script, but some subdirectories too
21# so these will be copied.
22
23if [ "x`uname`" = xSunOS ] ; then
24   cp -r patches/autom4te.cache patches/configure patches/configure.in src
25   if [ $? -ne 0 ]; then
26      echo "Failed to apply the Solaris patches needed for"
27      echo "http://bugs.python.org/issue1759169"
28      echo "http://trac.sagemath.org/sage_trac/ticket/7867"
29      exit 1
30   fi
31fi
32
33
34cp patches/locale.py src/Lib/locale.py
35if [ $? -ne 0 ]; then
36    echo "Error copying patched locale.py"
37    exit 1
38fi
39
40cp patches/sdist.py src/Lib/distutils/command/sdist.py
41if [ $? -ne 0 ]; then
42    echo "Error copying patched sdist.py"
43    exit 1
44fi
45
46cp patches/socket.py src/Lib/socket.py
47if [ $? -ne 0 ]; then
48    echo "Error copying patched socket.py"
49    exit 1
50fi
51
52cp patches/pickle.py src/Lib/pickle.py
53if [ $? -ne 0 ]; then
54    echo "Error copying patched pickle.py"
55    exit 1
56fi
57
58cp patches/cPickle.c src/Modules/cPickle.c
59if [ $? -ne 0 ]; then
60    echo "Error copying patched cPickle.c"
61    exit 1
62fi
63
64# The following patch for fixing broken readline behavior on Itanium
65# Linux definitely does *not* work on anything else.
66if [ "`uname -m`" = "ia64" -a "`uname`" = "Linux" ]; then
67    echo "Updating readline.c for Linux/Itanium"
68    cp patches/readline.c-Itanium-fix src/Modules/readline.c
69else
70    # Readline patch: http://bugs.python.org/file14599/python-2.6-readline.patch
71    # Associated bug: http://bugs.python.org/issue5833
72    #
73    # Committed to Python as r75747 in the py26-maint branch, but not
74    # in time for 2.6.4 -- so we can remove this patch the next time
75    # we update Python in Sage.
76    cp patches/readline.c-spacebug src/Modules/readline.c
77fi
78
79if [ $? -ne 0 ]; then
80    echo "Error copying patched readline.c"
81    exit 1
82fi
83
84
85# We are setting LDFLAGS and CPPFLAGS so that we pick up Sage's readline
86LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
87export LDFLAGS
88
89CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS"
90export CPPFLAGS
91
92# pymalloc screws with valgrind, so let's disable it
93if [ "$SAGE_VALGRIND" = "yes" ]; then
94    echo "Building Python without pymalloc"
95    EXTRAFLAGS="--without-pymalloc"; export EXTRAFLAGS
96fi
97
98# Program around weird bug in build process:
99#      Apparently if you have this:
100#         export DISTUTILS_DEBUG=1
101#      in your environment variables, the build craps out.  No idea why this
102#       is.
103#       -- Yi Qiang
104#
105# This bug was fixed in Python, but not yet in Python 2.6.4. So this fix
106# can be removed the next time we upgrade our version of Python. See
107#
108#   http://bugs.python.org/issue6954
109#
110# for the fix.
111#
112unset DISTUTILS_DEBUG
113
114
115cd src
116
117touch Include/*
118
119build()
120{
121    # do *not* put --enable-shared here!  this breaks building
122    # shared extension modules, at least in Python 2.5.
123    rm -f "$SAGE_LOCAL"/lib/libpython*
124
125    if [ `uname` = "Darwin" ]; then
126        if [ "x$SAGE64" = xyes ]; then
127            echo "64 bit OSX build enabled"
128            OPT="-g -O3 -m64 -Wall -Wstrict-prototypes"; export OPT
129            ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --without-libpng \
130            --enable-unicode=ucs4 --with-gcc="gcc -m64" --disable-toolbox-glue
131        else
132            ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --without-libpng \
133            --enable-unicode=ucs4 --disable-toolbox-glue
134        fi
135    elif [ `uname` = "SunOS" ]; then
136        if [ "x$SAGE64" = xyes ]; then
137            echo "64 bit Open Solaris build enabled"
138            OPT="-g -O3 -Wall -Wstrict-prototypes"; export OPT
139            ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --without-libpng \
140            --enable-unicode=ucs4 --with-gcc="gcc -m64"
141        else
142            ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --without-libpng \
143            --enable-unicode=ucs4
144        fi
145    else
146        ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --without-libpng --enable-unicode=ucs4 CC="$CC $CFLAGS" CXX="$CXX $CXXFLAGS"
147    fi
148
149
150    if [ $? -ne 0 ]; then
151        echo "Error configuring Python."
152        exit 1
153    fi
154
155    $MAKE
156    if [ $? -ne 0 ]; then
157        echo "Error building Python."
158        exit 1
159    fi
160
161    # running 'make install' in parallel is a bad, bad idea
162    MAKE=make; export MAKE
163    # the "-i" is crucial, esp. in the case of a major upgrade
164    make -i install
165    if [ $? -ne 0 ]; then
166        echo "Error installing Python."
167        exit 1
168    fi
169}
170
171# Do not exit script if there is an error, but instead print an
172# informative error message. This is helps in determining why the
173# configuration, compilation or installation failed. So put this before the
174# build() function.
175set +e
176
177build
178
179cd $SAGE_LOCAL/lib
180
181# move the python directory if we're upgrading from a version
182# of sage with python 2.5
183if [ -d python2.5/site-packages ]; then
184   mv python2.5/site-packages python2.6/site-packages-old
185fi
186
187rm -rf python/python2.6 python/python2.5 python/python python python2.4 python2.5
188ln -s python2.6 python
189if [ $? -ne 0 ]; then
190    echo "Error creating symbolic link"
191    exit 1
192fi
193
194# Sleeping for three seconds so that parallel 'make install' catches up
195# with the following test.
196echo "Sleeping for three seconds before testing python"
197sleep 3
198
199# Make sure sufficient crypto support is available in the built python.
200# This is critical.
201python -c "import hashlib"
202
203if [ $? -eq 0 -a -f "$SAGE_LOCAL/bin/python" ]; then
204    echo "hashlib module imported"
205    exit 0
206else
207    echo "hashlib module failed to import"
208    exit 1
209fi