blob: adf8977f216a47eeccac0d94b8d2ea8b164db389 [file] [log] [blame]
Mike Frysinger682d0652012-07-30 11:38:25 -04001Extensions should be installed to the targets libdir. This is important if e.g. host
2has a 64bit /usr/lib64, but the target is 32bit and has $ROOT/usr/lib. Make sure we
3respect the target's lib structure by getting the libdir name from Makefile.
4
5--- a/Lib/distutils/command/install.py
6+++ b/Lib/distutils/command/install.py
7@@ -38,8 +38,8 @@
8
9 INSTALL_SCHEMES = {
10 'unix_prefix': {
11- 'purelib': '$base/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
12- 'platlib': '$platbase/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
13+ 'purelib': '$base/$libdirname/python$py_version_short/site-packages',
14+ 'platlib': '$platbase/$libdirname/python$py_version_short/site-packages',
15 'headers': '$base/include/python$py_version_short/$dist_name',
16 'scripts': '$base/bin',
17 'data' : '$base',
18@@ -289,6 +289,7 @@
19 # everything else.
20 self.config_vars['base'] = self.install_base
21 self.config_vars['platbase'] = self.install_platbase
22+ self.config_vars['libdirname'] = self.install_libdirname
23
24 if DEBUG:
25 from pprint import pprint
26@@ -394,6 +395,10 @@
27
28 self.install_base = self.prefix
29 self.install_platbase = self.exec_prefix
30+ self.install_libdirname = os.path.basename(get_config_vars('LIBDIR')[0])
31+ if self.install_libdirname is None:
32+ self.install_libdirname = '@@GENTOO_LIBDIR@@'
33+
34 self.select_scheme("unix_prefix")
35
36 # finalize_unix ()
37--- a/Lib/distutils/command/build_ext.py
38+++ b/Lib/distutils/command/build_ext.py
39@@ -201,7 +201,8 @@
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040040 and sysconfig.get_config_var('Py_ENABLE_SHARED'):
Mike Frysinger682d0652012-07-30 11:38:25 -040041 if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
42 # building third party extensions
43- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
44+ sysroot = os.getenv('SYSROOT', '')
45+ self.library_dirs.append(sysroot + sysconfig.get_config_var('LIBDIR'))
46 else:
47 # building python standard extensions
48 self.library_dirs.append('.')
49--- a/Lib/distutils/sysconfig.py
50+++ b/Lib/distutils/sysconfig.py
Mike Frysinger51f0d522015-11-21 00:11:17 +000051@@ -12,6 +12,7 @@
52 __revision__ = "$Id$"
53
54 import os
55+import imp
56 import re
57 import string
58 import sys
59@@ -19,9 +20,16 @@
Mike Frysinger682d0652012-07-30 11:38:25 -040060 from distutils.errors import DistutilsPlatformError
61
62 # These are needed in a couple of spots, so just compute them once.
63+SYSROOT = os.getenv('SYSROOT', '')
64 PREFIX = os.path.normpath(sys.prefix)
65 EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
66
67+# Make sure we respect the user specified SYSROOT environment variable.
68+# This is the first step to get distutils to crosscompile stuff.
69+if SYSROOT:
70+ PREFIX = os.path.normpath(SYSROOT + os.path.sep + PREFIX)
71+ EXEC_PREFIX = os.path.normpath(SYSROOT + os.path.sep + EXEC_PREFIX)
72+
73 # Path to the base directory of the project. On Windows the binary may
74 # live in project/PCBuild9. If we're dealing with an x64 Windows build,
75 # it'll live in project/PCbuild/amd64.
Mike Frysinger51f0d522015-11-21 00:11:17 +000076@@ -114,13 +122,21 @@
Mike Frysinger682d0652012-07-30 11:38:25 -040077
78 If 'prefix' is supplied, use it instead of sys.prefix or
79 sys.exec_prefix -- i.e., ignore 'plat_specific'.
80+
81+ For the posix system we can not always assume the host's notion of the
82+ libdir is the same for the target. e.g. compiling on an x86_64 system
83+ will use 'lib64' but an arm 32bit target will use 'lib'. So encode all
84+ the known lists of dirs and search them all (starting with the host one
85+ so that native builds work just fine).
86 """
87 if prefix is None:
88 prefix = plat_specific and EXEC_PREFIX or PREFIX
Mike Frysinger682d0652012-07-30 11:38:25 -040089
90 if os.name == "posix":
91- libpython = os.path.join(prefix,
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040092- "@@GENTOO_LIBDIR@@", "python" + get_python_version())
Mike Frysinger682d0652012-07-30 11:38:25 -040093+ for libdir in ['@@GENTOO_LIBDIR@@', 'lib64', 'lib32', 'libx32', 'lib']:
94+ libpython = os.path.join(prefix, libdir, "python" + get_python_version())
95+ if os.path.exists(libpython):
96+ break
97 if standard_lib:
98 return libpython
99 else:
Mike Frysinger51f0d522015-11-21 00:11:17 +0000100@@ -409,10 +425,14 @@
101 def _init_posix():
102 """Initialize the module as appropriate for POSIX systems."""
103 # _sysconfigdata is generated at build time, see the sysconfig module
104- from _sysconfigdata import build_time_vars
105+ lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
106+ sysconfig_path = os.path.join(lib_dir, "_sysconfigdata.py")
107+ if not os.path.exists(sysconfig_path):
108+ _, sysconfig_path, _ = imp.find_module("_sysconfigdata")
109+ sysconfig_module = imp.load_source("_sysconfigdata", sysconfig_path)
110 global _config_vars
111 _config_vars = {}
112- _config_vars.update(build_time_vars)
113+ _config_vars.update(sysconfig_module.build_time_vars)
114
115
116 def _init_nt():