Skip to content

Commit

Permalink
sysconfig: treat MINGW builds as POSIX builds
Browse files Browse the repository at this point in the history
Co-authored-by: Алексей <[email protected]>
  • Loading branch information
Alexpux authored and lazka committed Aug 25, 2023
1 parent f59a672 commit e974a9d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Lib/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,18 @@
},
}

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

# For the OS-native venv scheme, we essentially provide an alias:
if os.name == 'nt':
if os.name == 'nt' and not _POSIX_BUILD:
_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['nt_venv']
else:
_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv']



# NOTE: site.py has copy of this function.
# Sync it when modify this function.
def _getuserbase():
Expand All @@ -119,7 +124,7 @@ def _getuserbase():
def joinuser(*args):
return os.path.expanduser(os.path.join(*args))

if os.name == "nt":
if os.name == "nt" and not _POSIX_BUILD:
base = os.environ.get("APPDATA") or "~"
return joinuser(base, "Python")

Expand Down Expand Up @@ -278,7 +283,7 @@ def _expand_vars(scheme, vars):


def _get_preferred_schemes():
if os.name == 'nt':
if os.name == 'nt' and not _POSIX_BUILD:
return {
'prefix': 'nt',
'home': 'posix_home',
Expand Down Expand Up @@ -607,7 +612,7 @@ def parse_config_h(fp, vars=None):
def get_config_h_filename():
"""Return the path of pyconfig.h."""
if _PYTHON_BUILD:
if os.name == "nt":
if os.name == "nt" and not _POSIX_BUILD:
inc_dir = os.path.join(_PROJECT_BASE, "PC")
else:
inc_dir = _PROJECT_BASE
Expand Down Expand Up @@ -683,10 +688,10 @@ def get_config_vars(*args):
except AttributeError:
_CONFIG_VARS['py_version_nodot_plat'] = ''

if os.name == 'nt':
if os.name == 'nt' and not _POSIX_BUILD:
_init_non_posix(_CONFIG_VARS)
_CONFIG_VARS['VPATH'] = sys._vpath
if os.name == 'posix':
if _POSIX_BUILD:
_init_posix(_CONFIG_VARS)
if _HAS_USER_BASE:
# Setting 'userbase' is done below the call to the
Expand All @@ -696,7 +701,7 @@ def get_config_vars(*args):

# Always convert srcdir to an absolute path
srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE)
if os.name == 'posix':
if _POSIX_BUILD:
if _PYTHON_BUILD:
# If srcdir is a relative path (typically '.' or '..')
# then it should be interpreted relative to the directory
Expand Down

0 comments on commit e974a9d

Please sign in to comment.