blob: c1b3dd6a30e4e39890b56aabd1d14cac928cff74 [file] [log] [blame]
Andrew Geisslerd5838332022-05-27 11:33:10 -05001From 41f78746cbe88d263400ee948abef5b3f89cce29 Mon Sep 17 00:00:00 2001
2From: 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>
18---
19 setuptools/_distutils/sysconfig.py | 14 +++++++++++---
20 1 file changed, 11 insertions(+), 3 deletions(-)
21
22diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py
23index 55a42e1..ead63b9 100644
24--- a/setuptools/_distutils/sysconfig.py
25+++ b/setuptools/_distutils/sysconfig.py
26@@ -102,7 +102,9 @@ def get_python_inc(plat_specific=0, prefix=None):
27 If 'prefix' is supplied, use it instead of sys.base_prefix or
28 sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
29 """
30- if prefix is None:
31+ if prefix is None and os.environ.get('STAGING_INCDIR', ""):
32+ prefix = os.environ['STAGING_INCDIR'].rstrip('include')
33+ elif prefix is None:
34 prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
35 if os.name == "posix":
36 if IS_PYPY and sys.version_info < (3, 8):
37@@ -167,7 +169,13 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
38
39 early_prefix = prefix
40
41- if prefix is None:
42+ if os.environ.get('STAGING_LIBDIR', ""):
43+ lib_basename = os.environ['STAGING_LIBDIR'].split('/')[-1]
44+ else:
45+ lib_basename = "lib"
46+ if prefix is None and os.environ.get('STAGING_LIBDIR', ""):
47+ prefix = os.environ['STAGING_LIBDIR'].rstrip(lib_basename)
48+ elif prefix is None:
49 if standard_lib:
50 prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
51 else:
52@@ -182,7 +190,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
53 # Pure Python
54 libdir = "lib"
55 implementation = 'pypy' if IS_PYPY else 'python'
56- libpython = os.path.join(prefix, libdir,
57+ libpython = os.path.join(prefix, lib_basename,
58 implementation + get_python_version())
59 return _posix_lib(standard_lib, libpython, early_prefix, prefix)
60 elif os.name == "nt":