From c0ec7506fbe7a483161e07103ca463d7afa75f97 Mon Sep 17 00:00:00 2001 From: Roumen Petrov Date: Sat, 2 Mar 2013 22:19:20 +0200 Subject: [PATCH 20/24] MINGW: generalization of posix build in sysconfig.py --- Lib/sysconfig.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py index 8720e50..1caa074 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -96,6 +96,9 @@ _BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix) _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: @@ -179,7 +182,7 @@ def _expand_vars(scheme, vars): 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 @@ -191,7 +194,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 "~" if env_base: return env_base @@ -460,7 +463,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(_sys_home or _PROJECT_BASE, "PC") else: inc_dir = _sys_home or _PROJECT_BASE @@ -531,9 +534,9 @@ def get_config_vars(*args): # sys.abiflags may not be defined on all platforms. _CONFIG_VARS['abiflags'] = '' - if os.name == 'nt': + if os.name == 'nt' 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 # init function to enable using 'get_config_var' in @@ -542,7 +545,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 -- 1.7.12.1