Skip to content

Commit 64afb6a

Browse files
Roumen Petrovmingwandroid
authored andcommitted
MINGW: generalization of posix build in sysconfig.py
1 parent d92f25b commit 64afb6a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Lib/sysconfig.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
_CONFIG_VARS = None
9696
_USER_BASE = None
9797

98+
# GCC[mingw*] use posix build system
99+
_POSIX_BUILD = os.name == 'posix' or \
100+
(os.name == "nt" and 'GCC' in sys.version)
98101

99102
def _safe_realpath(path):
100103
try:
@@ -178,7 +181,7 @@ def _expand_vars(scheme, vars):
178181

179182

180183
def _get_default_scheme():
181-
if os.name == 'posix':
184+
if _POSIX_BUILD:
182185
# the default scheme for posix is posix_prefix
183186
return 'posix_prefix'
184187
return os.name
@@ -190,7 +193,7 @@ def _getuserbase():
190193
def joinuser(*args):
191194
return os.path.expanduser(os.path.join(*args))
192195

193-
if os.name == "nt":
196+
if os.name == "nt" and not _POSIX_BUILD:
194197
base = os.environ.get("APPDATA") or "~"
195198
if env_base:
196199
return env_base
@@ -475,7 +478,7 @@ def parse_config_h(fp, vars=None):
475478
def get_config_h_filename():
476479
"""Return the path of pyconfig.h."""
477480
if _PYTHON_BUILD:
478-
if os.name == "nt":
481+
if os.name == "nt" and not _POSIX_BUILD:
479482
inc_dir = os.path.join(_sys_home or _PROJECT_BASE, "PC")
480483
else:
481484
inc_dir = _sys_home or _PROJECT_BASE
@@ -546,9 +549,9 @@ def get_config_vars(*args):
546549
# sys.abiflags may not be defined on all platforms.
547550
_CONFIG_VARS['abiflags'] = ''
548551

549-
if os.name == 'nt':
552+
if os.name == 'nt' and not _POSIX_BUILD:
550553
_init_non_posix(_CONFIG_VARS)
551-
if os.name == 'posix':
554+
if _POSIX_BUILD:
552555
_init_posix(_CONFIG_VARS)
553556
# For backward compatibility, see issue19555
554557
SO = _CONFIG_VARS.get('EXT_SUFFIX')
@@ -561,7 +564,7 @@ def get_config_vars(*args):
561564

562565
# Always convert srcdir to an absolute path
563566
srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE)
564-
if os.name == 'posix':
567+
if _POSIX_BUILD:
565568
if _PYTHON_BUILD:
566569
# If srcdir is a relative path (typically '.' or '..')
567570
# then it should be interpreted relative to the directory

0 commit comments

Comments
 (0)