#9958: Upgrade python to 2.7
---------------------------+------------------------------------------------
Reporter: mhampton | Owner: tbd
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-4.8
Component: packages | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies: #11986
---------------------------+------------------------------------------------
Comment(by leif):
Indeed, there've been '''a lot of''' changes inbetween:
{{{
#!diff
diff -Nu python-2.7.1/spkg-install python-2.6.4.p11/spkg-install
--- python-2.7.1/spkg-install 2011-05-20 05:41:41.000000000 +0200
+++ python-2.6.4.p11/spkg-install 2011-07-05 10:46:40.000000000
+0200
@@ -5,50 +5,127 @@
CUR=`pwd`
-if [ "$SAGE_LOCAL" = "" ]; then
- echo "SAGE_LOCAL undefined ... exiting";
- echo "Maybe run 'sage -sh'?"
- exit 1
+if [ -z "$SAGE_LOCAL" ]; then
+ echo >&2 "SAGE_LOCAL undefined ... exiting"
+ echo >&2 "Maybe run 'sage -sh'?"
+ exit 1
fi
# PATCH
-# Due to issues building Python on Ubuntu 11.04, a file is patched
-# on these systems.
+# When building Python 2.6 on Debian and derivatives with multiarch,
+# system library directories are not correctly setup. This patch
+# fixes this, with no-op on other systems.
+# The fix requires 'dpkg-architecture' to be installed there though
+# (see below).
+echo "Patching src/setup.py for multiarch."
+patch -p0 < patches/setup.py.multiarch.patch
+if [ $? -ne 0 ]; then
+ echo >&2 "Error patching src/setup.py"
+ exit 1
+fi
-if [ -f /etc/issue ] && grep "Ubuntu 11.04" /etc/issue ; then
- echo "Patching src/Modules/Setup.dist as this is Ubuntu 11.04"
- patch -p0 < patches/Modules.Setup.dist.patch
+# Due to a python bug with Solaris
+# see http://bugs.python.org/issue1759169
+# it is necessary to apply a patch to configure.in
+# then run autoconf. This not only generates a
+# new 'configure' script, but some subdirectories too
+# so these will be copied.
+
+if [ "x`uname`" = xSunOS ] ; then
+ echo "Applying a revised 'configure' script for Solaris"
+ echo "See http://bugs.python.org/issue1759169"
+ echo "http://trac.sagemath.org/sage_trac/ticket/7867"
+ cp -r patches/autom4te.cache patches/configure patches/configure.in
src
if [ $? -ne 0 ]; then
- echo "Error patching src/Modules/Setup.dist"
+ echo >&2 "Failed to apply the Solaris patches needed for"
+ echo >&2 "http://bugs.python.org/issue1759169"
+ echo >&2 "http://trac.sagemath.org/sage_trac/ticket/7867"
exit 1
fi
+ echo "Setting HAVE_FD_TRANSFER=0 for Solaris to allow"
+ echo "the python module '_multiprocessing' to build"
+ echo "See: http://trac.sagemath.org/sage_trac/ticket/8440"
+ cp patches/setup.py src
+ if [ $? -ne 0 ]; then
+ echo >&2 "Failed to apply the Solaris patch needed for"
+ echo >&2 "http://trac.sagemath.org/sage_trac/ticket/8440"
+ exit 1
+ fi
+fi
+
+
+cp patches/locale.py src/Lib/locale.py
+if [ $? -ne 0 ]; then
+ echo >&2 "Error copying patched locale.py"
+ exit 1
fi
-patch -p0 < patches/Lib.distutils.command.sdist.patch
+cp patches/Makefile.pre.in src/Makefile.pre.in
if [ $? -ne 0 ]; then
- echo "Error copying patched sdist.py"
+ echo >&2 "Error copying patched Makefile.pre.in"
exit 1
fi
-patch -p0 < patches/Lib.socket.patch
+cp patches/sdist.py src/Lib/distutils/command/sdist.py
if [ $? -ne 0 ]; then
- echo "Error copying patched socket.py"
+ echo >&2 "Error copying patched sdist.py"
exit 1
fi
-patch -p0 < patches/dynamic_class_copyreg_py.patch
+cp patches/socket.py src/Lib/socket.py
if [ $? -ne 0 ]; then
- echo "Error copying patched pickle.py"
+ echo >&2 "Error copying patched socket.py"
exit 1
fi
-patch -p0 < patches/dynamic_class_copyreg_c.patch
+cp patches/pickle.py src/Lib/pickle.py
if [ $? -ne 0 ]; then
- echo "Error copying patched cPickle.c"
+ echo >&2 "Error copying patched pickle.py"
exit 1
fi
+cp patches/cPickle.c src/Modules/cPickle.c
+if [ $? -ne 0 ]; then
+ echo >&2 "Error copying patched cPickle.c"
+ exit 1
+fi
+
+# Due to a problem with _socket not building on OpenSolaris on x64
+# see http://bugs.python.org/issue8852
+# http://trac.sagemath.org/sage_trac/ticket/9041
+# http://trac.sagemath.org/sage_trac/ticket/9022
+# Modules/socketmodule.c needs patching. The patch consists of
+# only checking if things are defined before trying to build with them
+# so it is safe (and desirable) on any platform.
+
+cp patches/Modules.socketmodule.c src/Modules/socketmodule.c
+if [ $? -ne 0 ]; then
+ echo >&2 "Error copying patched socketmodule.c"
+ exit 1
+fi
+
+# The following patch for fixing broken readline behavior on Itanium
+# Linux definitely does *not* work on anything else.
+if [ "`uname -m`" = "ia64" -a "`uname`" = "Linux" ]; then
+ echo "Updating readline.c for Linux/Itanium"
+ cp patches/readline.c-Itanium-fix src/Modules/readline.c
+else
+ # Readline patch:
http://bugs.python.org/file14599/python-2.6-readline.patch
+ # Associated bug: http://bugs.python.org/issue5833
+ #
+ # Committed to Python as r75747 in the py26-maint branch, but not
+ # in time for 2.6.4 -- so we can remove this patch the next time
+ # we update Python in Sage.
+ cp patches/readline.c-spacebug src/Modules/readline.c
+fi
+
+if [ $? -ne 0 ]; then
+ echo >&2 "Error copying patched readline.c"
+ exit 1
+fi
+
+
# We are setting LDFLAGS and CPPFLAGS so that we pick up Sage's readline
LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
export LDFLAGS
@@ -62,6 +139,23 @@
EXTRAFLAGS="--without-pymalloc"; export EXTRAFLAGS
fi
+# Program around weird bug in build process:
+# Apparently if you have this:
+# export DISTUTILS_DEBUG=1
+# in your environment variables, the build craps out. No idea why
this
+# is.
+# -- Yi Qiang
+#
+# This bug was fixed in Python, but not yet in Python 2.6.4. So this fix
+# can be removed the next time we upgrade our version of Python. See
+#
+# http://bugs.python.org/issue6954
+#
+# for the fix.
+#
+unset DISTUTILS_DEBUG
+
+
cd src
touch Include/*
@@ -93,27 +187,30 @@
--enable-unicode=ucs4
fi
else
- ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --enable-
unicode=ucs4 CC="$CC $CFLAGS" CXX="$CXX $CXXFLAGS"
+ ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL" --enable-
unicode=ucs4 \
+ CC="$CC $CFLAGS" CXX="$CXX $CXXFLAGS"
fi
if [ $? -ne 0 ]; then
- echo "Error configuring Python."
+ echo >&2 "Error configuring Python."
exit 1
fi
$MAKE
if [ $? -ne 0 ]; then
- echo "Error building Python."
+ echo >&2 "Error building Python."
exit 1
fi
# running 'make install' in parallel is a bad, bad idea
+ # FIXME: The proper way to disable parallel make is to use
+ # $MAKE -j1 ... (We rely on GNU make anyway).
MAKE=make; export MAKE
# the "-i" is crucial, esp. in the case of a major upgrade
make -i install
if [ $? -ne 0 ]; then
- echo "Error installing Python."
+ echo >&2 "Error installing Python."
exit 1
fi
}
@@ -122,27 +219,28 @@
# informative error message. This is helps in determining why the
# configuration, compilation or installation failed. So put this before
the
# build() function.
-set +e
+set +e # This is redundant here, but doesn't hurt to keep it... ;-)
build
-cd $SAGE_LOCAL/lib
+cd "$SAGE_LOCAL/lib"
# move the python directory if we're upgrading from a version
-# of sage with python 2.6
-if [ -d python2.6/site-packages ]; then
- mv python2.6/site-packages python2.7/site-packages-old
+# of sage with python 2.5
+if [ -d python2.5/site-packages ]; then
+ mv python2.5/site-packages python2.6/site-packages-old
fi
-rm -rf python/python2.7 python/python2.6 python/python2.5 python/python
python python2.4 python2.5
-ln -s python2.7 python
+rm -rf python/python2.6 python/python2.5 python/python python python2.4
python2.5
+ln -s python2.6 python
if [ $? -ne 0 ]; then
- echo "Error creating symbolic link"
+ echo >&2 "Error creating symbolic link"
exit 1
fi
# Sleeping for three seconds so that parallel 'make install' catches up
# with the following test.
+# XXX We have disabled parallel 'make install' above, but never mind.
echo "Sleeping for three seconds before testing python"
sleep 3
@@ -150,12 +248,28 @@
# All these modules are important and if any one
# fails to build, Sage will not work.
+import_errors=false
for module in math hashlib crypt ; do
"$SAGE_LOCAL/bin/python" -c "import $module"
if [ $? -eq 0 ] ; then
echo "$module module imported OK"
else
- echo "$module module failed to import"
- exit 1
+ echo >&2 "$module module failed to import"
+ import_errors=true
+ # exit 1 # not yet
fi
done
+
+if $import_errors; then
+ echo >&2 "Error: One or more modules failed to import."
+ # Check if we are on Debian or one of its derivatives:
+ if command -v dpkg && ! command -v dpkg-architecture >/dev/null; then
+ echo >&2 "You may have to install 'dpkg-architecture'"
+ echo >&2 "which is part of the Debian package 'dpkg-dev'."
+ echo >&2 "Try installing it by typing"
+ echo >&2 " sudo apt-get install dpkg-dev"
+ echo >&2 "and rerun 'make'."
+ fi
+ exit 1
+fi
+
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9958#comment:137>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.