diff -rupN --no-dereference Python-3.10.0rc1/Lib/distutils/sysconfig.py Python-3.10.0rc1-new/Lib/distutils/sysconfig.py
--- Python-3.10.0rc1/Lib/distutils/sysconfig.py 2021-08-04 16:36:58.970361746 +0200
+++ Python-3.10.0rc1-new/Lib/distutils/sysconfig.py 2021-08-04 16:36:59.191359517 +0200
@@ -182,6 +182,17 @@ def parse_makefile(fn, g=None):
# Following functions are deprecated together with this module and they
# have no direct replacement
+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
# an in-source build.
@@ -279,7 +290,7 @@ def get_python_inc(plat_specific=0, pref
"""
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
@@ -326,7 +337,7 @@ def get_python_lib(plat_specific=0, stan
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX
- if os.name == "posix":
+ if posix_build:
if plat_specific or standard_lib:
# Platform-specific modules (any module from a non-pure-Python
# module distribution) or standard Python library modules.
diff -rupN --no-dereference Python-3.10.0rc1/Lib/site.py Python-3.10.0rc1-new/Lib/site.py
--- Python-3.10.0rc1/Lib/site.py 2021-08-02 21:53:59.000000000 +0200
+++ Python-3.10.0rc1-new/Lib/site.py 2021-08-04 16:36:59.191359517 +0200
@@ -273,7 +273,8 @@ def _getuserbase():
def joinuser(*args):
return os.path.expanduser(os.path.join(*args))
- if os.name == "nt":
+ from sysconfig import _POSIX_BUILD
+ if os.name == "nt" and not _POSIX_BUILD:
base = os.environ.get("APPDATA") or "~"
return joinuser(base, "Python")
@@ -288,7 +289,8 @@ def _getuserbase():
def _get_path(userbase):
version = sys.version_info
- if os.name == 'nt':
+ from sysconfig import _POSIX_BUILD
+ if sys.platform == 'win32' and not _POSIX_BUILD:
ver_nodot = sys.winver.replace('.', '')
return f'{userbase}\\Python{ver_nodot}\\site-packages'
@@ -356,6 +358,7 @@ def getsitepackages(prefixes=None):
if prefixes is None:
prefixes = PREFIXES
+ from sysconfig import _POSIX_BUILD
for prefix in prefixes:
if not prefix or prefix in seen:
continue
@@ -365,7 +368,7 @@ def getsitepackages(prefixes=None):
if sys.platlibdir != "lib":
libdirs.append("lib")
- if os.sep == '/':
+ if _POSIX_BUILD:
for libdir in libdirs:
path = os.path.join(prefix, libdir,
"python%d.%d" % sys.version_info[:2],
diff -rupN --no-dereference Python-3.10.0rc1/Lib/sysconfig.py Python-3.10.0rc1-new/Lib/sysconfig.py
--- Python-3.10.0rc1/Lib/sysconfig.py 2021-08-04 16:36:59.188359547 +0200
+++ Python-3.10.0rc1-new/Lib/sysconfig.py 2021-08-04 16:36:59.191359517 +0200
@@ -5,6 +5,10 @@ import sys
import textwrap
from os.path import pardir, realpath
+# GCC[mingw*] use posix build system
+_POSIX_BUILD = os.name == 'posix' or \
+ (os.name == "nt" and 'GCC' in sys.version)
+
__all__ = [
'get_config_h_filename',
'get_config_var',
@@ -74,7 +78,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")
@@ -137,7 +141,6 @@ _variable_rx = r"([a-zA-Z][a-zA-Z0-9_]+)
_findvar1_rx = r"\$\(([A-Za-z][A-Za-z0-9_]*)\)"
_findvar2_rx = r"\${([A-Za-z][A-Za-z0-9_]*)}"
-
def _safe_realpath(path):
try:
return realpath(path)
@@ -226,7 +229,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',
@@ -552,7 +555,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
@@ -628,9 +631,9 @@ 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)
- if os.name == 'posix':
+ if _POSIX_BUILD:
_init_posix(_CONFIG_VARS)
# For backward compatibility, see issue19555
SO = _CONFIG_VARS.get('EXT_SUFFIX')
@@ -644,7 +647,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