Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 1 | From 3fd8fcd33d2b0f3ac2fc043eac8641ab4432967d Mon Sep 17 00:00:00 2001 |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 2 | From: Alexander Kanavin <alex@linutronix.de> |
| 3 | Date: Wed, 11 May 2022 21:41:14 +0200 |
| 4 | Subject: [PATCH] _distutils/sysconfig.py: make it possible to substite the |
| 5 | prefix to target sysroot |
| 6 | |
| 7 | This is done by probing STAGING_INCDIR/STAGING_LIBDIRenv vars: |
| 8 | not the most elegant solution, but distutils/sysconfig has been |
| 9 | tweaked to do this for many, many year, and so it's easiest |
| 10 | to replicate here as well, the original is |
| 11 | meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch |
| 12 | |
| 13 | I'm not sure exactly why setuptools now needs a copy, and what |
| 14 | would happen to this module in light of distutils deprecation. |
| 15 | |
| 16 | Upstream-Status: Inappropriate [oe-core specific] |
| 17 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 18 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 19 | --- |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 20 | setuptools/_distutils/sysconfig.py | 12 ++++++++++-- |
| 21 | 1 file changed, 10 insertions(+), 2 deletions(-) |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 22 | |
| 23 | diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 24 | index e41d51e..c17a79a 100644 |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 25 | --- a/setuptools/_distutils/sysconfig.py |
| 26 | +++ b/setuptools/_distutils/sysconfig.py |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 27 | @@ -119,6 +119,8 @@ def get_python_inc(plat_specific=0, prefix=None): |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 28 | sys.base_exec_prefix -- i.e., ignore 'plat_specific'. |
| 29 | """ |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 30 | 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 Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 37 | |
| 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 Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 51 | @@ -236,7 +244,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 52 | # Pure Python |
| 53 | libdir = "lib" |
| 54 | implementation = 'pypy' if IS_PYPY else 'python' |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 55 | - libpython = os.path.join(prefix, libdir, implementation + get_python_version()) |
| 56 | + libpython = os.path.join(prefix, lib_basename, implementation + get_python_version()) |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 57 | return _posix_lib(standard_lib, libpython, early_prefix, prefix) |
| 58 | elif os.name == "nt": |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 59 | if standard_lib: |