@@ -64,8 +64,23 @@ def parse_config_h(fp, g=None):
64
64
65
65
_python_build = partial (is_python_build , check_home = True )
66
66
_init_posix = partial (sysconfig_init_posix , _config_vars )
67
- _init_nt = partial (_init_non_posix , _config_vars )
68
67
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 )
69
84
70
85
# Similar function is also implemented in sysconfig as _parse_makefile
71
86
# but without the parsing capabilities of distutils.text_file.TextFile.
@@ -290,7 +305,7 @@ def get_python_inc(plat_specific=0, prefix=None):
290
305
"""
291
306
if prefix is None :
292
307
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
293
- if os . name == "posix" :
308
+ if posix_build :
294
309
if python_build :
295
310
# Assume the executable is in the build directory. The
296
311
# 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):
337
352
else :
338
353
prefix = plat_specific and EXEC_PREFIX or PREFIX
339
354
340
- if os . name == "posix" :
355
+ if posix_build :
341
356
if plat_specific or standard_lib :
342
357
# Platform-specific modules (any module from a non-pure-Python
343
358
# module distribution) or standard Python library modules.
0 commit comments