python: update to 2.6.8
This pulls down fixes from upstream, and folds in some more
cross-compiling work needed for the new version.
BUG=chromium-os:32539
TEST=`cbuildbot chromiumos-sdk` passes
Change-Id: I98af1683f19eb64abd9cd6ad1e248d953857a034
Reviewed-on: https://gerrit.chromium.org/gerrit/28700
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/dev-lang/python/files/python-2.6.8-cross-setup-sysroot.patch b/dev-lang/python/files/python-2.6.8-cross-setup-sysroot.patch
new file mode 100644
index 0000000..70f3f3c
--- /dev/null
+++ b/dev-lang/python/files/python-2.6.8-cross-setup-sysroot.patch
@@ -0,0 +1,169 @@
+Change setup.py to respect the SYSROOT environment variable
+
+--- a/setup.py
++++ b/setup.py
+@@ -337,9 +337,13 @@
+
+ def detect_modules(self):
+ global disable_ssl
++
++ # We must respect the user specified sysroot!
++ sysroot = os.getenv('SYSROOT', '')
++
+ # Ensure that /usr/local is always used
+- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++ add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/local/lib')
++ add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/local/include')
+
+ # Add paths specified in the environment variables LDFLAGS and
+ # CPPFLAGS for header and library files.
+@@ -375,12 +381,18 @@
+ for directory in reversed(options.dirs):
+ add_dir_to_list(dir_list, directory)
+
+- if os.path.normpath(sys.prefix) != '/usr':
++ if os.path.normpath(sys.prefix) != '/usr/local':
+ add_dir_to_list(self.compiler.library_dirs,
+ sysconfig.get_config_var("LIBDIR"))
+ add_dir_to_list(self.compiler.include_dirs,
+ sysconfig.get_config_var("INCLUDEDIR"))
+
++ # We should always look into sysroot/usr/include and consider
++ # also the lib dirs there for searching for files
++ add_dir_to_list(self.compiler.include_dirs, sysroot + '/usr/include')
++ add_dir_to_list(self.compiler.library_dirs, sysroot + '/@@GENTOO_LIBDIR@@')
++ add_dir_to_list(self.compiler.library_dirs, sysroot + '/usr/@@GENTOO_LIBDIR@@')
++
+ try:
+ have_unicode = unicode
+ except NameError:
+@@ -389,6 +403,9 @@
+ '/lib', '/usr/lib',
+ ]
+ inc_dirs = self.compiler.include_dirs + ['/usr/include']
++ # Ignore previous settings.
++ lib_dirs = self.compiler.library_dirs
++ inc_dirs = self.compiler.include_dirs
+ exts = []
+ missing = []
+
+@@ -613,11 +624,11 @@
+ elif self.compiler.find_library_file(lib_dirs, 'curses'):
+ readline_libs.append('curses')
+ elif self.compiler.find_library_file(lib_dirs +
+- ['/usr/@@GENTOO_LIBDIR@@/termcap'],
++ [sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'],
+ 'termcap'):
+ readline_libs.append('termcap')
+ exts.append( Extension('readline', ['readline.c'],
+- library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'],
++ library_dirs=[sysroot + '/usr/@@GENTOO_LIBDIR@@/termcap'],
+ extra_link_args=readline_extra_link_args,
+ libraries=readline_libs) )
+ else:
+@@ -642,20 +653,20 @@
+ depends = ['socketmodule.h']) )
+ # Detect SSL support for the socket module (via _ssl)
+ search_for_ssl_incs_in = [
+- '/usr/local/ssl/include',
+- '/usr/contrib/ssl/include/'
++ sysroot + '/usr/local/ssl/include',
++ sysroot + '/usr/contrib/ssl/include/'
+ ]
+ ssl_incs = find_file('openssl/ssl.h', inc_dirs,
+ search_for_ssl_incs_in
+ )
+ if ssl_incs is not None and not disable_ssl:
+ krb5_h = find_file('krb5.h', inc_dirs,
+- ['/usr/kerberos/include'])
++ [sysroot + '/usr/kerberos/include'])
+ if krb5_h:
+ ssl_incs += krb5_h
+ ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
+- ['/usr/local/ssl/lib',
+- '/usr/contrib/ssl/lib/'
++ [sysroot + '/usr/local/ssl/lib',
++ sysroot + '/usr/contrib/ssl/lib/'
+ ] )
+
+ if (ssl_incs is not None and
+@@ -773,6 +785,7 @@
+ db_inc_paths.append('/usr/local/include/db3%d' % x)
+ db_inc_paths.append('/pkg/db-3.%d/include' % x)
+ db_inc_paths.append('/opt/db-3.%d/include' % x)
++ db_inc_paths = [sysroot + x for x in db_inc_paths]
+
+ # Add some common subdirectories for Sleepycat DB to the list,
+ # based on the standard include directories. This way DB3/4 gets
+@@ -921,5 +933,6 @@
+ '/usr/local/include/sqlite',
+ '/usr/local/include/sqlite3',
+ ]
++ sqlite_inc_paths = [sysroot + x for x in sqlite_inc_paths]
+ MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
+ MIN_SQLITE_VERSION = ".".join([str(x)
+@@ -1021,7 +1033,7 @@
+ # we do not build this one. Otherwise this build will pick up
+ # the more recent berkeleydb's db.h file first in the include path
+ # when attempting to compile and it will fail.
+- f = "/usr/include/db.h"
++ f = sysroot + "/usr/include/db.h"
+
+ if sys.platform == 'darwin':
+ if is_macosx_sdk_path(f):
+@@ -1236,7 +1248,7 @@
+ # More information on Expat can be found at www.libexpat.org.
+ #
+ # Use system expat
+- expatinc = '/usr/include'
++ expatinc = sysroot + '/usr/include'
+ define_macros = []
+
+ exts.append(Extension('pyexpat',
+@@ -1546,7 +1558,7 @@
+ # For 8.4a2, the X11 headers are not included. Rather than include a
+ # complicated search, this is a hard-coded path. It could bail out
+ # if X11 libs are not found...
+- include_dirs.append('/usr/X11R6/include')
++ include_dirs.append(sysroot + '/usr/X11R6/include')
+ frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
+
+ # All existing framework builds of Tcl/Tk don't support 64-bit
+@@ -1579,6 +1591,9 @@
+ def detect_tkinter(self, inc_dirs, lib_dirs):
+ # The _tkinter module.
+
++ # We must respect the user specified sysroot!
++ sysroot = os.getenv('SYSROOT', '')
++
+ # Rather than complicate the code below, detecting and building
+ # AquaTk is a separate method. Only one Tkinter will be built on
+ # Darwin - either AquaTk, if it is found, or X11 based Tk.
+@@ -1633,17 +1650,17 @@
+ if platform == 'sunos5':
+ include_dirs.append('/usr/openwin/include')
+ added_lib_dirs.append('/usr/openwin/lib')
+- elif os.path.exists('/usr/X11R6/include'):
+- include_dirs.append('/usr/X11R6/include')
+- added_lib_dirs.append('/usr/X11R6/lib64')
+- added_lib_dirs.append('/usr/X11R6/lib')
+- elif os.path.exists('/usr/X11R5/include'):
+- include_dirs.append('/usr/X11R5/include')
+- added_lib_dirs.append('/usr/X11R5/lib')
++ elif os.path.exists(sysroot + '/usr/X11R6/include'):
++ include_dirs.append(sysroot + '/usr/X11R6/include')
++ added_lib_dirs.append(sysroot + '/usr/X11R6/lib64')
++ added_lib_dirs.append(sysroot + '/usr/X11R6/lib')
++ elif os.path.exists(sysroot + '/usr/X11R5/include'):
++ include_dirs.append(sysroot + '/usr/X11R5/include')
++ added_lib_dirs.append(sysroot + '/usr/X11R5/lib')
+ else:
+ # Assume default location for X11
+- include_dirs.append('/usr/X11/include')
+- added_lib_dirs.append('/usr/X11/lib')
++ include_dirs.append(sysroot + '/usr/X11/include')
++ added_lib_dirs.append(sysroot + '/usr/X11/lib')
+
+ # If Cygwin, then verify that X is installed before proceeding
+ if platform == 'cygwin':