fix(dev-lang/python): Update python build for cross-compiling.

Port the ChromiumOS distutils and site patches from 2.7.3 to 2.7.5 and
add some additional exports to make autoconf happy.
This commit is contained in:
Michael Marineau 2013-09-10 22:10:18 -04:00
parent 24402086f8
commit e041f799a1
2 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,96 @@
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 923197b..b6ee689 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -239,7 +239,8 @@ class build_ext (Command):
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('.')
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index a2822e8..ab7f8e8 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -41,8 +41,8 @@ else:
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',
@@ -319,6 +319,7 @@ class install (Command):
# 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
@@ -435,6 +436,10 @@ class install (Command):
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 ()
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index e16b05c..c67434a 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -19,9 +19,16 @@ import sys
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.
@@ -114,13 +121,21 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
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
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:
--
1.8.1.5

View File

@ -102,6 +102,17 @@ src_prepare() {
epatch "${FILESDIR}/${P}-re_unsigned_ptrdiff.patch" #476426
epatch "${FILESDIR}/CVE-2013-4238_py27.patch"
#
# START: ChromiumOS specific changes
#
epatch "${FILESDIR}"/python-2.7.5-cross-distutils.patch
sed -i -e "s:sys.exec_prefix]:sys.exec_prefix, '/usr/local']:g" \
Lib/site.py || die "sed failed to add /usr/local to prefixes"
#
# END: ChromiumOS specific changes
#
sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
Lib/distutils/command/install.py \
Lib/distutils/sysconfig.py \
@ -183,6 +194,10 @@ src_configure() {
# The configure script assumes it's buggy when cross-compiling.
export ac_cv_buggy_getaddrinfo=no
export ac_cv_have_long_long_format=yes
# The configure script requires this to be explicit
export ac_cv_file__dev_ptmx=yes
export ac_cv_file__dev_ptc=no
fi
# Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.