Skip to content

Commit 7a8eda8

Browse files
Alexpuxnaveen521kk
authored andcommitted
distutils: generalization of posix build in distutils sys
Co-authored-by: Naveen M K <naveen521kk@gmail.com>
1 parent e0f7adc commit 7a8eda8

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Lib/distutils/sysconfig.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,23 @@ def parse_config_h(fp, g=None):
6464

6565
_python_build = partial(is_python_build, check_home=True)
6666
_init_posix = partial(sysconfig_init_posix, _config_vars)
67-
_init_nt = partial(_init_non_posix, _config_vars)
6867

68+
def _posix_build():
69+
# GCC[mingw*] use posix build system
70+
# Check for cross builds explicitly
71+
host_platform = os.environ.get("_PYTHON_HOST_PLATFORM")
72+
if host_platform:
73+
if host_platform.startswith('mingw'):
74+
return True
75+
return os.name == 'posix' or \
76+
(os.name == "nt" and 'GCC' in sys.version)
77+
posix_build = _posix_build()
78+
79+
80+
def _init_nt():
81+
if posix_build:
82+
return _init_posix(_config_vars)
83+
return _init_non_posix(_config_vars)
6984

7085
# Similar function is also implemented in sysconfig as _parse_makefile
7186
# but without the parsing capabilities of distutils.text_file.TextFile.
@@ -290,7 +305,7 @@ def get_python_inc(plat_specific=0, prefix=None):
290305
"""
291306
if prefix is None:
292307
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
293-
if os.name == "posix":
308+
if posix_build:
294309
if python_build:
295310
# Assume the executable is in the build directory. The
296311
# 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):
337352
else:
338353
prefix = plat_specific and EXEC_PREFIX or PREFIX
339354

340-
if os.name == "posix":
355+
if posix_build:
341356
if plat_specific or standard_lib:
342357
# Platform-specific modules (any module from a non-pure-Python
343358
# module distribution) or standard Python library modules.

0 commit comments

Comments
 (0)