smlinux/base/python3/python3-sysconfig-prefix.patch
2022-01-28 23:06:05 +05:30

58 lines
2.6 KiB
Diff

this patch fixes 3 things:
1) native: if prefix is empty, use "/" to construct the pathname, otherwise
we will end up with something like `-I include/python2.7`
2) cross-compile: if we're cross-compiling, we're reusing the
PKG_CONFIG_SYSROOT_DIR environment variable to prefix the include/lib path.
this though helps only when the system doing the crosscompile uses the so-
patched python. we therefore assume a sabotage host system is used.
3) previously, the right logic for selecting LD_SHARED was only used on Mac.
it should be done on any POSIX system (CC overrides).
--- Python-3.7.3.orig/Lib/distutils/sysconfig.py
+++ Python-3.7.3/Lib/distutils/sysconfig.py
@@ -92,7 +92,7 @@
If 'prefix' is supplied, use it instead of sys.base_prefix or
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
- if prefix is None:
+ if prefix is None or prefix == '':
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
if os.name == "posix":
if python_build:
@@ -107,7 +107,8 @@
incdir = os.path.join(get_config_var('srcdir'), 'Include')
return os.path.normpath(incdir)
python_dir = 'python' + get_python_version() + build_flags
- return os.path.join(prefix, "include", python_dir)
+ sysroot = os.environ.get('PKG_CONFIG_SYSROOT_DIR', '')
+ return os.path.join(sysroot + prefix, "include", python_dir)
elif os.name == "nt":
if python_build:
# Include both the include and PC dir to ensure we can find
@@ -135,14 +136,15 @@
If 'prefix' is supplied, use it instead of sys.base_prefix or
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
- if prefix is None:
+ if prefix is None or prefix == '':
if standard_lib:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX
if os.name == "posix":
- libpython = os.path.join(prefix,
+ sysroot = os.environ.get('PKG_CONFIG_SYSROOT_DIR', '')
+ libpython = os.path.join(sysroot + prefix,
"lib", "python" + get_python_version())
if standard_lib:
return libpython
@@ -189,7 +191,7 @@
if 'CC' in os.environ:
newcc = os.environ['CC']
- if (sys.platform == 'darwin'
+ if ((sys.platform == 'darwin' or os.name == 'posix')
and 'LDSHARED' not in os.environ
and ldshared.startswith(cc)):
# On OS X, if CC is overridden, use that as the default