MINGW-packages/mingw-w64-python/0074-distutils-generalization-of-posix-build-in-distutils.patch

60 lines
2.2 KiB
Diff

From 6555128293ef0dc537a3e458852f1a8e55cdda93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
<alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:41 +0530
Subject: [PATCH 074/N] distutils: generalization of posix build in distutils
sys
Co-authored-by: Naveen M K <naveen521kk@gmail.com>
---
Lib/distutils/sysconfig.py | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index c1dd2a4..024c15c 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -64,8 +64,23 @@ def parse_config_h(fp, g=None):
_python_build = partial(is_python_build, check_home=True)
_init_posix = partial(sysconfig_init_posix, _config_vars)
-_init_nt = partial(_init_non_posix, _config_vars)
+def _posix_build():
+ # GCC[mingw*] use posix build system
+ # Check for cross builds explicitly
+ host_platform = os.environ.get("_PYTHON_HOST_PLATFORM")
+ if host_platform:
+ if host_platform.startswith('mingw'):
+ return True
+ return os.name == 'posix' or \
+ (os.name == "nt" and 'GCC' in sys.version)
+posix_build = _posix_build()
+
+
+def _init_nt():
+ if posix_build:
+ return _init_posix(_config_vars)
+ return _init_non_posix(_config_vars)
# Similar function is also implemented in sysconfig as _parse_makefile
# but without the parsing capabilities of distutils.text_file.TextFile.
@@ -290,7 +305,7 @@ def get_python_inc(plat_specific=0, prefix=None):
"""
if prefix is None:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
- if os.name == "posix":
+ if posix_build:
if python_build:
# Assume the executable is in the build directory. The
# pyconfig.h file should be in the same directory. Since
@@ -337,7 +352,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX
- if os.name == "posix":
+ if posix_build:
if plat_specific or standard_lib:
# Platform-specific modules (any module from a non-pure-Python
# module distribution) or standard Python library modules.