python3: Update to 3.11.3, refresh/redo patches
[feed/packages.git] / lang / python / python3 / patches / 008-distutils-use-python-sysroot.patch
1 From e359a7a3c4f9e70360a068bef19c95938fdacede 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
5
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).
11
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.
16
17 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
18 ---
19 Lib/distutils/command/build_ext.py | 5 ++++-
20 Lib/sysconfig.py | 15 +++++++++++----
21 2 files changed, 15 insertions(+), 5 deletions(-)
22
23 --- a/Lib/distutils/command/build_ext.py
24 +++ b/Lib/distutils/command/build_ext.py
25 @@ -234,7 +234,10 @@ class build_ext(Command):
26 if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
27 if not sysconfig.python_build:
28 # building third party extensions
29 - self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
30 + libdir = sysconfig.get_config_var('LIBDIR')
31 + if "_python_sysroot" in os.environ:
32 + libdir = os.environ.get("_python_sysroot") + libdir
33 + self.library_dirs.append(libdir)
34 else:
35 # building python standard extensions
36 self.library_dirs.append('.')
37 --- a/Lib/sysconfig.py
38 +++ b/Lib/sysconfig.py
39 @@ -168,10 +168,17 @@ _SCHEME_KEYS = ('stdlib', 'platstdlib',
40 _PY_VERSION = sys.version.split()[0]
41 _PY_VERSION_SHORT = f'{sys.version_info[0]}.{sys.version_info[1]}'
42 _PY_VERSION_SHORT_NO_DOT = f'{sys.version_info[0]}{sys.version_info[1]}'
43 -_PREFIX = os.path.normpath(sys.prefix)
44 -_BASE_PREFIX = os.path.normpath(sys.base_prefix)
45 -_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
46 -_BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
47 +if "_python_sysroot" in os.environ:
48 + _sysroot=os.environ.get('_python_sysroot')
49 + _PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
50 + _EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
51 + _BASE_PREFIX = _PREFIX
52 + _BASE_EXEC_PREFIX = _EXEC_PREFIX
53 +else:
54 + _PREFIX = os.path.normpath(sys.prefix)
55 + _EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
56 + _BASE_PREFIX = os.path.normpath(sys.base_prefix)
57 + _BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
58 _CONFIG_VARS = None
59 _USER_BASE = None
60