diff -rupN Python-2.7.13/Lib/sysconfig.py Python-2.7.13-new/Lib/sysconfig.py --- Python-2.7.13/Lib/sysconfig.py 2017-01-21 01:46:08.289588519 +0100 +++ Python-2.7.13-new/Lib/sysconfig.py 2017-01-21 01:46:08.714583981 +0100 @@ -94,6 +94,10 @@ _EXEC_PREFIX = os.path.normpath(sys.exec _CONFIG_VARS = None _USER_BASE = None +# GCC[mingw*] use posix build system +_POSIX_BUILD = os.name == 'posix' or \ + (os.name == "nt" and 'GCC' in sys.version) + def _safe_realpath(path): try: return realpath(path) @@ -162,7 +166,7 @@ def _expand_vars(scheme, vars): return res def _get_default_scheme(): - if os.name == 'posix': + if _POSIX_BUILD: # the default scheme for posix is posix_prefix return 'posix_prefix' return os.name @@ -173,7 +177,7 @@ def _getuserbase(): return os.path.expanduser(os.path.join(*args)) # what about 'os2emx', 'riscos' ? - if os.name == "nt": + if os.name == "nt" and not _POSIX_BUILD: base = os.environ.get("APPDATA") or "~" return env_base if env_base else joinuser(base, "Python") @@ -418,7 +422,7 @@ def parse_config_h(fp, vars=None): def get_config_h_filename(): """Returns 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 @@ -480,9 +484,9 @@ def get_config_vars(*args): _CONFIG_VARS['platbase'] = _EXEC_PREFIX _CONFIG_VARS['projectbase'] = _PROJECT_BASE - if os.name in ('nt', 'os2'): + if os.name in ('nt', 'os2') and not _POSIX_BUILD: _init_non_posix(_CONFIG_VARS) - if os.name == 'posix': + if _POSIX_BUILD: _init_posix(_CONFIG_VARS) # Setting 'userbase' is done below the call to the @@ -497,7 +501,7 @@ def get_config_vars(*args): # Normally it is relative to the build directory. However, during # testing, for example, we might be running a non-installed python # from a different directory. - if _PYTHON_BUILD and os.name == "posix": + if _PYTHON_BUILD and _POSIX_BUILD: base = _PROJECT_BASE try: cwd = os.getcwd()