151 lines
7.0 KiB
Diff
151 lines
7.0 KiB
Diff
From 449580a3d2646c863ea82352bfaeb26fc27d2081 Mon Sep 17 00:00:00 2001
|
|
From: Naveen M K <naveen521kk@gmail.com>
|
|
Date: Wed, 19 Jan 2022 20:01:45 +0530
|
|
Subject: [PATCH 109/N] Change user site-packages path to include the
|
|
environment info
|
|
|
|
This should avoid mixing of user site-packages between python
|
|
from various environments. Previously, the user site-packages
|
|
should be located at `~/.local/lib/python3.10` for all environment
|
|
including 32-bits variants which caused problems with 64-bit trying to
|
|
load 32-bit extensions. Now this path will be changed to
|
|
`~/.local/lib/python3.10-<platform tag here>`, for example, in
|
|
CLANG64 this would be `~/.local/lib/python3.10-mingw_x86_64_clang`.
|
|
|
|
Fixes https://github.com/msys2-contrib/cpython-mingw/issues/40
|
|
---
|
|
Lib/distutils/command/install.py | 5 +++--
|
|
Lib/site.py | 28 +++++++++++++++++++++++++---
|
|
Lib/sysconfig.py | 26 +++++++++++++++-----------
|
|
3 files changed, 43 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
|
|
index 9cb3b2c..25eb3d8 100644
|
|
--- a/Lib/distutils/command/install.py
|
|
+++ b/Lib/distutils/command/install.py
|
|
@@ -72,7 +72,7 @@
|
|
INSTALL_SCHEMES['nt_user'] = {
|
|
'purelib': '$usersite',
|
|
'platlib': '$usersite',
|
|
- 'headers': '$userbase/include/python$py_version_short$abiflags/$dist_name',
|
|
+ 'headers': '$userbase/include/python$py_version_short_plat$abiflags/$dist_name',
|
|
'scripts': '$userbase/bin',
|
|
'data' : '$userbase',
|
|
}
|
|
@@ -81,7 +81,7 @@
|
|
'purelib': '$usersite',
|
|
'platlib': '$usersite',
|
|
'headers':
|
|
- '$userbase/include/python$py_version_short$abiflags/$dist_name',
|
|
+ '$userbase/include/python$py_version_short_plat$abiflags/$dist_name',
|
|
'scripts': '$userbase/bin',
|
|
'data' : '$userbase',
|
|
}
|
|
@@ -311,6 +311,7 @@ def finalize_options(self):
|
|
'py_version': py_version,
|
|
'py_version_short': '%d.%d' % sys.version_info[:2],
|
|
'py_version_nodot': '%d%d' % sys.version_info[:2],
|
|
+ 'py_version_short_plat': f'{sys.version_info[0]}.{sys.version_info[1]}-{get_platform()}' if os.name == 'nt' and 'gcc' in sys.version.lower() else f'{sys.version_info[0]}.{sys.version_info[1]}',
|
|
'sys_prefix': prefix,
|
|
'prefix': prefix,
|
|
'sys_exec_prefix': exec_prefix,
|
|
diff --git a/Lib/site.py b/Lib/site.py
|
|
index 9dc38a6..41b9cf1 100644
|
|
--- a/Lib/site.py
|
|
+++ b/Lib/site.py
|
|
@@ -289,14 +289,36 @@ def joinuser(*args):
|
|
|
|
return joinuser("~", ".local")
|
|
|
|
+# Copy of sysconfig.get_platform() but only for MinGW
|
|
+def _get_platform():
|
|
+ if os.name == 'nt':
|
|
+ if 'gcc' in sys.version.lower():
|
|
+ if 'ucrt' in sys.version.lower():
|
|
+ if 'amd64' in sys.version.lower():
|
|
+ return 'mingw_x86_64_ucrt'
|
|
+ return 'mingw_i686_ucrt'
|
|
+ if 'clang' in sys.version.lower():
|
|
+ if 'amd64' in sys.version.lower():
|
|
+ return 'mingw_x86_64_clang'
|
|
+ if 'arm64' in sys.version.lower():
|
|
+ return 'mingw_aarch64'
|
|
+ if 'arm' in sys.version.lower():
|
|
+ return 'mingw_armv7'
|
|
+ return 'mingw_i686_clang'
|
|
+ if 'amd64' in sys.version.lower():
|
|
+ return 'mingw_x86_64'
|
|
+ return 'mingw_i686'
|
|
+ return sys.platform
|
|
|
|
# Same to sysconfig.get_path('purelib', os.name+'_user')
|
|
def _get_path(userbase):
|
|
version = sys.version_info
|
|
|
|
- if os.name == 'nt' and not _POSIX_BUILD:
|
|
- ver_nodot = sys.winver.replace('.', '')
|
|
- return f'{userbase}\\Python{ver_nodot}\\site-packages'
|
|
+ if os.name == 'nt':
|
|
+ if not _POSIX_BUILD:
|
|
+ ver_nodot = sys.winver.replace('.', '')
|
|
+ return f'{userbase}\\Python{ver_nodot}\\site-packages'
|
|
+ return f'{userbase}/lib/python{version[0]}.{version[1]}-{_get_platform()}/site-packages'
|
|
|
|
if sys.platform == 'darwin' and sys._framework:
|
|
return f'{userbase}/lib/python/site-packages'
|
|
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
|
index da3db6d..f359835 100644
|
|
--- a/Lib/sysconfig.py
|
|
+++ b/Lib/sysconfig.py
|
|
@@ -140,20 +140,20 @@ def joinuser(*args):
|
|
_INSTALL_SCHEMES |= {
|
|
# NOTE: When modifying "purelib" scheme, update site._get_path() too.
|
|
'nt_user': {
|
|
- 'stdlib': '{userbase}/lib/python{py_version_short}',
|
|
- 'platstdlib': '{userbase}/lib/python{py_version_short}',
|
|
- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
|
|
- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
|
|
- 'include': '{userbase}/include/python{py_version_short}',
|
|
+ 'stdlib': '{userbase}/lib/python{py_version_short_plat}',
|
|
+ 'platstdlib': '{userbase}/lib/python{py_version_short_plat}',
|
|
+ 'purelib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
|
|
+ 'platlib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
|
|
+ 'include': '{userbase}/include/python{py_version_short_plat}',
|
|
'scripts': '{userbase}/bin',
|
|
'data': '{userbase}',
|
|
},
|
|
'posix_user': {
|
|
- 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}',
|
|
- 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}',
|
|
- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
|
|
- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
|
|
- 'include': '{userbase}/include/python{py_version_short}',
|
|
+ 'stdlib': '{userbase}/{platlibdir}/python{py_version_short_plat}',
|
|
+ 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short_plat}',
|
|
+ 'purelib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
|
|
+ 'platlib': '{userbase}/lib/python{py_version_short_plat}/site-packages',
|
|
+ 'include': '{userbase}/include/python{py_version_short_plat}',
|
|
'scripts': '{userbase}/bin',
|
|
'data': '{userbase}',
|
|
},
|
|
@@ -695,6 +695,10 @@ def get_config_vars(*args):
|
|
_CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '')
|
|
except AttributeError:
|
|
_CONFIG_VARS['py_version_nodot_plat'] = ''
|
|
+ if os.name == 'nt' and _POSIX_BUILD:
|
|
+ _CONFIG_VARS['py_version_short_plat'] = f'{_PY_VERSION_SHORT}-{get_platform()}'
|
|
+ else:
|
|
+ _CONFIG_VARS['py_version_short_plat'] = _PY_VERSION_SHORT
|
|
|
|
if os.name == 'nt' and not _POSIX_BUILD:
|
|
_init_non_posix(_CONFIG_VARS)
|
|
@@ -747,7 +751,7 @@ def get_config_var(name):
|
|
"""
|
|
return get_config_vars().get(name)
|
|
|
|
-
|
|
+# make sure to change site._get_platform() while changing this function
|
|
def get_platform():
|
|
"""Return a string that identifies the current platform.
|
|
|