blob: e1960b8d9f4d601070083ba0e13b862895abb682 [file] [log] [blame]
Andrew Geissler615f2f12022-07-15 14:00:58 -05001From 3fd8fcd33d2b0f3ac2fc043eac8641ab4432967d Mon Sep 17 00:00:00 2001
Andrew Geisslerd5838332022-05-27 11:33:10 -05002From: Alexander Kanavin <alex@linutronix.de>
3Date: Wed, 11 May 2022 21:41:14 +0200
4Subject: [PATCH] _distutils/sysconfig.py: make it possible to substite the
5 prefix to target sysroot
6
7This is done by probing STAGING_INCDIR/STAGING_LIBDIRenv vars:
8not the most elegant solution, but distutils/sysconfig has been
9tweaked to do this for many, many year, and so it's easiest
10to replicate here as well, the original is
11meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch
12
13I'm not sure exactly why setuptools now needs a copy, and what
14would happen to this module in light of distutils deprecation.
15
16Upstream-Status: Inappropriate [oe-core specific]
17Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Andrew Geissler615f2f12022-07-15 14:00:58 -050018
Andrew Geisslerd5838332022-05-27 11:33:10 -050019---
Andrew Geissler615f2f12022-07-15 14:00:58 -050020 setuptools/_distutils/sysconfig.py | 12 ++++++++++--
21 1 file changed, 10 insertions(+), 2 deletions(-)
Andrew Geisslerd5838332022-05-27 11:33:10 -050022
23diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py
Andrew Geissler615f2f12022-07-15 14:00:58 -050024index e41d51e..c17a79a 100644
Andrew Geisslerd5838332022-05-27 11:33:10 -050025--- a/setuptools/_distutils/sysconfig.py
26+++ b/setuptools/_distutils/sysconfig.py
Andrew Geissler615f2f12022-07-15 14:00:58 -050027@@ -119,6 +119,8 @@ def get_python_inc(plat_specific=0, prefix=None):
Andrew Geisslerd5838332022-05-27 11:33:10 -050028 sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
29 """
Andrew Geissler615f2f12022-07-15 14:00:58 -050030 default_prefix = BASE_EXEC_PREFIX if plat_specific else BASE_PREFIX
31+ if os.environ.get('STAGING_INCDIR', ""):
32+ default_prefix = os.environ['STAGING_INCDIR'].rstrip('include')
33 resolved_prefix = prefix if prefix is not None else default_prefix
34 try:
35 getter = globals()[f'_get_python_inc_{os.name}']
36@@ -221,7 +223,13 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
Andrew Geisslerd5838332022-05-27 11:33:10 -050037
38 early_prefix = prefix
39
40- if prefix is None:
41+ if os.environ.get('STAGING_LIBDIR', ""):
42+ lib_basename = os.environ['STAGING_LIBDIR'].split('/')[-1]
43+ else:
44+ lib_basename = "lib"
45+ if prefix is None and os.environ.get('STAGING_LIBDIR', ""):
46+ prefix = os.environ['STAGING_LIBDIR'].rstrip(lib_basename)
47+ elif prefix is None:
48 if standard_lib:
49 prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
50 else:
Andrew Geissler615f2f12022-07-15 14:00:58 -050051@@ -236,7 +244,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
Andrew Geisslerd5838332022-05-27 11:33:10 -050052 # Pure Python
53 libdir = "lib"
54 implementation = 'pypy' if IS_PYPY else 'python'
Andrew Geissler615f2f12022-07-15 14:00:58 -050055- libpython = os.path.join(prefix, libdir, implementation + get_python_version())
56+ libpython = os.path.join(prefix, lib_basename, implementation + get_python_version())
Andrew Geisslerd5838332022-05-27 11:33:10 -050057 return _posix_lib(standard_lib, libpython, early_prefix, prefix)
58 elif os.name == "nt":
Andrew Geissler615f2f12022-07-15 14:00:58 -050059 if standard_lib: