python: update to 2.7.3
BUG=chromium:206038
TEST=`emerge python -1u` worked
TEST=`cbuildbot chromiumos-sdk` worked
TEST=`cbuildbot {arm,amd64,x86}-generic-full` worked
TEST=`cbuildbot link-firmware` worked
TEST=`cbuildbot {stumpy,lumpy,daisy,x86-alex}-release` worked
CQ-DEPEND=CL:45833
CQ-DEPEND=CL:45839
CQ-DEPEND=CL:45866
CQ-DEPEND=CL:46602
CQ-DEPEND=CL:46730
Change-Id: I591df26efef43bbfd90bdf8084d3e40bddb8c5ee
Reviewed-on: https://gerrit.chromium.org/gerrit/45835
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/dev-lang/python/files/python-2.7.3-cross-distutils.patch b/dev-lang/python/files/python-2.7.3-cross-distutils.patch
new file mode 100644
index 0000000..1644cb6
--- /dev/null
+++ b/dev-lang/python/files/python-2.7.3-cross-distutils.patch
@@ -0,0 +1,93 @@
+Extensions should be installed to the targets libdir. This is important if e.g. host
+has a 64bit /usr/lib64, but the target is 32bit and has $ROOT/usr/lib. Make sure we
+respect the target's lib structure by getting the libdir name from Makefile.
+
+--- a/Lib/distutils/command/install.py
++++ b/Lib/distutils/command/install.py
+@@ -38,8 +38,8 @@
+
+ INSTALL_SCHEMES = {
+ 'unix_prefix': {
+- 'purelib': '$base/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
+- 'platlib': '$platbase/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
++ 'purelib': '$base/$libdirname/python$py_version_short/site-packages',
++ 'platlib': '$platbase/$libdirname/python$py_version_short/site-packages',
+ 'headers': '$base/include/python$py_version_short/$dist_name',
+ 'scripts': '$base/bin',
+ 'data' : '$base',
+@@ -289,6 +289,7 @@
+ # everything else.
+ self.config_vars['base'] = self.install_base
+ self.config_vars['platbase'] = self.install_platbase
++ self.config_vars['libdirname'] = self.install_libdirname
+
+ if DEBUG:
+ from pprint import pprint
+@@ -394,6 +395,10 @@
+
+ self.install_base = self.prefix
+ self.install_platbase = self.exec_prefix
++ self.install_libdirname = os.path.basename(get_config_vars('LIBDIR')[0])
++ if self.install_libdirname is None:
++ self.install_libdirname = '@@GENTOO_LIBDIR@@'
++
+ self.select_scheme("unix_prefix")
+
+ # finalize_unix ()
+--- a/Lib/distutils/command/build_ext.py
++++ b/Lib/distutils/command/build_ext.py
+@@ -201,7 +201,8 @@
+ and sysconfig.get_config_var('Py_ENABLE_SHARED'):
+ if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
+ # building third party extensions
+- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
++ sysroot = os.getenv('SYSROOT', '')
++ self.library_dirs.append(sysroot + sysconfig.get_config_var('LIBDIR'))
+ else:
+ # building python standard extensions
+ self.library_dirs.append('.')
+--- a/Lib/distutils/sysconfig.py
++++ b/Lib/distutils/sysconfig.py
+@@ -19,9 +19,16 @@
+ from distutils.errors import DistutilsPlatformError
+
+ # These are needed in a couple of spots, so just compute them once.
++SYSROOT = os.getenv('SYSROOT', '')
+ PREFIX = os.path.normpath(sys.prefix)
+ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+
++# Make sure we respect the user specified SYSROOT environment variable.
++# This is the first step to get distutils to crosscompile stuff.
++if SYSROOT:
++ PREFIX = os.path.normpath(SYSROOT + os.path.sep + PREFIX)
++ EXEC_PREFIX = os.path.normpath(SYSROOT + os.path.sep + EXEC_PREFIX)
++
+ # Path to the base directory of the project. On Windows the binary may
+ # live in project/PCBuild9. If we're dealing with an x64 Windows build,
+ # it'll live in project/PCbuild/amd64.
+@@ -110,6 +117,12 @@
+
+ If 'prefix' is supplied, use it instead of sys.prefix or
+ sys.exec_prefix -- i.e., ignore 'plat_specific'.
++
++ For the posix system we can not always assume the host's notion of the
++ libdir is the same for the target. e.g. compiling on an x86_64 system
++ will use 'lib64' but an arm 32bit target will use 'lib'. So encode all
++ the known lists of dirs and search them all (starting with the host one
++ so that native builds work just fine).
+ """
+ if prefix is None:
+ prefix = plat_specific and EXEC_PREFIX or PREFIX
+@@ -119,8 +119,10 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
+ prefix = plat_specific and EXEC_PREFIX or PREFIX
+
+ if os.name == "posix":
+- libpython = os.path.join(prefix,
+- "@@GENTOO_LIBDIR@@", "python" + get_python_version())
++ for libdir in ['@@GENTOO_LIBDIR@@', 'lib64', 'lib32', 'libx32', 'lib']:
++ libpython = os.path.join(prefix, libdir, "python" + get_python_version())
++ if os.path.exists(libpython):
++ break
+ if standard_lib:
+ return libpython
+ else: