blob: 1644cb6016c109f0f3d55dc2e6cd6c9bcb94e444 [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
Cheng-Yi Chiangb88f6962015-08-06 13:49:23 +000051@@ -19,9 +19,16 @@
Mike Frysinger682d0652012-07-30 11:38:25 -040052 from distutils.errors import DistutilsPlatformError
53
54 # These are needed in a couple of spots, so just compute them once.
55+SYSROOT = os.getenv('SYSROOT', '')
56 PREFIX = os.path.normpath(sys.prefix)
57 EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
58
59+# Make sure we respect the user specified SYSROOT environment variable.
60+# This is the first step to get distutils to crosscompile stuff.
61+if SYSROOT:
62+ PREFIX = os.path.normpath(SYSROOT + os.path.sep + PREFIX)
63+ EXEC_PREFIX = os.path.normpath(SYSROOT + os.path.sep + EXEC_PREFIX)
64+
65 # Path to the base directory of the project. On Windows the binary may
66 # live in project/PCBuild9. If we're dealing with an x64 Windows build,
67 # it'll live in project/PCbuild/amd64.
Cheng-Yi Chiangb88f6962015-08-06 13:49:23 +000068@@ -110,6 +117,12 @@
Mike Frysinger682d0652012-07-30 11:38:25 -040069
70 If 'prefix' is supplied, use it instead of sys.prefix or
71 sys.exec_prefix -- i.e., ignore 'plat_specific'.
72+
73+ For the posix system we can not always assume the host's notion of the
74+ libdir is the same for the target. e.g. compiling on an x86_64 system
75+ will use 'lib64' but an arm 32bit target will use 'lib'. So encode all
76+ the known lists of dirs and search them all (starting with the host one
77+ so that native builds work just fine).
78 """
79 if prefix is None:
80 prefix = plat_specific and EXEC_PREFIX or PREFIX
Cheng-Yi Chiangb88f6962015-08-06 13:49:23 +000081@@ -119,8 +119,10 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
82 prefix = plat_specific and EXEC_PREFIX or PREFIX
Mike Frysinger682d0652012-07-30 11:38:25 -040083
84 if os.name == "posix":
85- libpython = os.path.join(prefix,
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040086- "@@GENTOO_LIBDIR@@", "python" + get_python_version())
Mike Frysinger682d0652012-07-30 11:38:25 -040087+ for libdir in ['@@GENTOO_LIBDIR@@', 'lib64', 'lib32', 'libx32', 'lib']:
88+ libpython = os.path.join(prefix, libdir, "python" + get_python_version())
89+ if os.path.exists(libpython):
90+ break
91 if standard_lib:
92 return libpython
93 else: