Skip to content

Commit

Permalink
Issue python#18640: MINGW: generalization of posix build in distutils…
Browse files Browse the repository at this point in the history
…/sysconfig.py
  • Loading branch information
Roumen Petrov authored and Faraz Shahbazker committed Sep 17, 2019
1 parent 0027dc1 commit d9d47df
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Lib/distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,18 @@ def _python_build():
if _sys_home:
return _is_python_source_dir(_sys_home)
return _is_python_source_dir(project_base)

python_build = _python_build()

def _posix_build():
# GCC[mingw*] use posix build system
# Check for cross builds explicitly
host_platform = os.environ.get("_PYTHON_HOST_PLATFORM")
if host_platform:
if host_platform.startswith('mingw'):
return True
return os.name == 'posix' or \
(os.name == "nt" and 'GCC' in sys.version)
posix_build = _posix_build()

# Calculate the build qualifier flags if they are defined. Adding the flags
# to the include and lib directories only makes sense for an installation, not
Expand Down Expand Up @@ -99,7 +108,7 @@ def get_python_inc(plat_specific=0, prefix=None):
"""
if prefix is None:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
if os.name == "posix":
if posix_build:
if python_build:
# Assume the executable is in the build directory. The
# pyconfig.h file should be in the same directory. Since
Expand Down Expand Up @@ -146,7 +155,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX

if os.name == "posix":
if posix_build:
libpython = os.path.join(prefix,
"lib", "python" + get_python_version())
if standard_lib:
Expand Down Expand Up @@ -241,7 +250,7 @@ def customize_compiler(compiler):
def get_config_h_filename():
"""Return full pathname of installed pyconfig.h file."""
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
Expand Down Expand Up @@ -447,6 +456,9 @@ def _init_posix():


def _init_nt():
if posix_build:
_init_posix()
return
"""Initialize the module as appropriate for NT"""
g = {}
# set basic install directories
Expand Down Expand Up @@ -496,7 +508,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 All @@ -515,7 +527,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
if (not os.path.isabs(_config_vars['srcdir']) and
base != os.getcwd()):
Expand Down

0 comments on commit d9d47df

Please sign in to comment.