python-pyasn: bump to version 1.6.0b1
[buildroot-gz.git] / package / python3 / 0007-Adjust-library-header-paths-for-cross-compilation.patch
blob9ac65ba93b76da7a41eca89fd31469b4d5b4e089
1 From e634929f76a45f5b683dc19bc01efed2ab83e19e Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Wed, 23 Dec 2015 11:33:14 +0100
4 Subject: [PATCH] Adjust library/header paths for cross-compilation
6 When cross-compiling third-party extensions, the get_python_inc() or
7 get_python_lib() can be called, to return the path to headers or
8 libraries. However, they use the sys.prefix of the host Python, which
9 returns incorrect paths when cross-compiling (paths pointing to host
10 headers and libraries).
12 In order to fix this, we introduce the _python_sysroot, _python_prefix
13 and _python_exec_prefix variables, that allow to override these
14 values, and get correct header/library paths when cross-compiling
15 third-party Python modules.
17 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
18 ---
19 Lib/distutils/command/build_ext.py | 5 ++++-
20 Lib/distutils/sysconfig.py | 15 +++++++++++----
21 2 files changed, 15 insertions(+), 5 deletions(-)
23 diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
24 index d4cb11e..e7a0ba9 100644
25 --- a/Lib/distutils/command/build_ext.py
26 +++ b/Lib/distutils/command/build_ext.py
27 @@ -232,7 +232,10 @@ class build_ext(Command):
28 if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
29 if not sysconfig.python_build:
30 # building third party extensions
31 - self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
32 + libdir = sysconfig.get_config_var('LIBDIR')
33 + if "_python_sysroot" in os.environ:
34 + libdir = os.environ.get("_python_sysroot") + libdir
35 + self.library_dirs.append(libdir)
36 else:
37 # building python standard extensions
38 self.library_dirs.append('.')
39 diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
40 index 721edec..d20e2d8 100644
41 --- a/Lib/distutils/sysconfig.py
42 +++ b/Lib/distutils/sysconfig.py
43 @@ -17,10 +17,17 @@ import sys
44 from .errors import DistutilsPlatformError
46 # These are needed in a couple of spots, so just compute them once.
47 -PREFIX = os.path.normpath(sys.prefix)
48 -EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
49 -BASE_PREFIX = os.path.normpath(sys.base_prefix)
50 -BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
51 +if "_python_sysroot" in os.environ:
52 + _sysroot=os.environ.get('_python_sysroot')
53 + PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
54 + EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
55 + BASE_PREFIX = PREFIX
56 + BASE_EXEC_PREFIX = EXEC_PREFIX
57 +else:
58 + PREFIX = os.path.normpath(sys.prefix)
59 + EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
60 + BASE_PREFIX = os.path.normpath(sys.base_prefix)
61 + BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
63 # Path to the base directory of the project. On Windows the binary may
64 # live in project/PCBuild/win32 or project/PCBuild/amd64.
65 --
66 2.6.4