Skip to content

Commit a5cb0a2

Browse files
Alexpuxlazka
authored andcommitted
sysconfig: treat MINGW builds as POSIX builds
Co-authored-by: Алексей <[email protected]>
1 parent 849236e commit a5cb0a2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Lib/sysconfig.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,18 @@
9898
},
9999
}
100100

101+
# GCC[mingw*] use posix build system
102+
_POSIX_BUILD = os.name == 'posix' or \
103+
(os.name == "nt" and 'GCC' in sys.version)
104+
101105
# For the OS-native venv scheme, we essentially provide an alias:
102-
if os.name == 'nt':
106+
if os.name == 'nt' and not _POSIX_BUILD:
103107
_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['nt_venv']
104108
else:
105109
_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv']
106110

107111

112+
108113
# NOTE: site.py has copy of this function.
109114
# Sync it when modify this function.
110115
def _getuserbase():
@@ -119,7 +124,7 @@ def _getuserbase():
119124
def joinuser(*args):
120125
return os.path.expanduser(os.path.join(*args))
121126

122-
if os.name == "nt":
127+
if os.name == "nt" and not _POSIX_BUILD:
123128
base = os.environ.get("APPDATA") or "~"
124129
return joinuser(base, "Python")
125130

@@ -278,7 +283,7 @@ def _expand_vars(scheme, vars):
278283

279284

280285
def _get_preferred_schemes():
281-
if os.name == 'nt':
286+
if os.name == 'nt' and not _POSIX_BUILD:
282287
return {
283288
'prefix': 'nt',
284289
'home': 'posix_home',
@@ -607,7 +612,7 @@ def parse_config_h(fp, vars=None):
607612
def get_config_h_filename():
608613
"""Return the path of pyconfig.h."""
609614
if _PYTHON_BUILD:
610-
if os.name == "nt":
615+
if os.name == "nt" and not _POSIX_BUILD:
611616
inc_dir = os.path.join(_PROJECT_BASE, "PC")
612617
else:
613618
inc_dir = _PROJECT_BASE
@@ -683,10 +688,10 @@ def get_config_vars(*args):
683688
except AttributeError:
684689
_CONFIG_VARS['py_version_nodot_plat'] = ''
685690

686-
if os.name == 'nt':
691+
if os.name == 'nt' and not _POSIX_BUILD:
687692
_init_non_posix(_CONFIG_VARS)
688693
_CONFIG_VARS['VPATH'] = sys._vpath
689-
if os.name == 'posix':
694+
if _POSIX_BUILD:
690695
_init_posix(_CONFIG_VARS)
691696
if _HAS_USER_BASE:
692697
# Setting 'userbase' is done below the call to the
@@ -696,7 +701,7 @@ def get_config_vars(*args):
696701

697702
# Always convert srcdir to an absolute path
698703
srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE)
699-
if os.name == 'posix':
704+
if _POSIX_BUILD:
700705
if _PYTHON_BUILD:
701706
# If srcdir is a relative path (typically '.' or '..')
702707
# then it should be interpreted relative to the directory

0 commit comments

Comments
 (0)