]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41627: Distinguish 32 and 64-bit user site packages on Windows (GH-22098)
authorSteve Dower <steve.dower@python.org>
Fri, 4 Sep 2020 23:45:54 +0000 (00:45 +0100)
committerGitHub <noreply@github.com>
Fri, 4 Sep 2020 23:45:54 +0000 (00:45 +0100)
Also fixes the error message returned when sysconfig fails to interpolate a variable correctly.

Lib/site.py
Lib/sysconfig.py
Misc/NEWS.d/next/Windows/2020-09-04-21-35-28.bpo-41627.sx2KN1.rst [new file with mode: 0644]

index 8979365cafc37e78bc2ce97f3299968f9a0a3678..4c095774729c5e6d7e08bc24466f2a7639c9fff9 100644 (file)
@@ -274,7 +274,8 @@ def _get_path(userbase):
     version = sys.version_info
 
     if os.name == 'nt':
-        return f'{userbase}\\Python{version[0]}{version[1]}\\site-packages'
+        ver_nodot = sys.winver.replace('.', '')
+        return f'{userbase}\\Python{ver_nodot}\\site-packages'
 
     if sys.platform == 'darwin' and sys._framework:
         return f'{userbase}/lib/python/site-packages'
index bf04ac541e6b027f3be0a96f874088c3ea6626f7..6c87b06634c4579ce82eb90ea1f755b5c4c0b2a8 100644 (file)
@@ -53,12 +53,12 @@ _INSTALL_SCHEMES = {
         },
     # NOTE: When modifying "purelib" scheme, update site._get_path() too.
     'nt_user': {
-        'stdlib': '{userbase}/Python{py_version_nodot}',
-        'platstdlib': '{userbase}/Python{py_version_nodot}',
-        'purelib': '{userbase}/Python{py_version_nodot}/site-packages',
-        'platlib': '{userbase}/Python{py_version_nodot}/site-packages',
-        'include': '{userbase}/Python{py_version_nodot}/Include',
-        'scripts': '{userbase}/Python{py_version_nodot}/Scripts',
+        'stdlib': '{userbase}/Python{py_version_nodot_plat}',
+        'platstdlib': '{userbase}/Python{py_version_nodot_plat}',
+        'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
+        'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages',
+        'include': '{userbase}/Python{py_version_nodot_plat}/Include',
+        'scripts': '{userbase}/Python{py_version_nodot_plat}/Scripts',
         'data': '{userbase}',
         },
     'posix_user': {
@@ -149,10 +149,10 @@ if _PYTHON_BUILD:
 def _subst_vars(s, local_vars):
     try:
         return s.format(**local_vars)
-    except KeyError:
+    except KeyError as var:
         try:
             return s.format(**os.environ)
-        except KeyError as var:
+        except KeyError:
             raise AttributeError('{%s}' % var) from None
 
 def _extend_dict(target_dict, other_dict):
@@ -431,6 +431,7 @@ def _init_non_posix(vars):
     vars['EXE'] = '.exe'
     vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
     vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
+    vars['TZPATH'] = ''
 
 #
 # public APIs
@@ -543,10 +544,13 @@ def get_config_vars(*args):
         except AttributeError:
             # sys.abiflags may not be defined on all platforms.
             _CONFIG_VARS['abiflags'] = ''
+        try:
+            _CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '')
+        except AttributeError:
+            _CONFIG_VARS['py_version_nodot_plat'] = ''
 
         if os.name == 'nt':
             _init_non_posix(_CONFIG_VARS)
-            _CONFIG_VARS['TZPATH'] = ''
         if os.name == 'posix':
             _init_posix(_CONFIG_VARS)
         # For backward compatibility, see issue19555
diff --git a/Misc/NEWS.d/next/Windows/2020-09-04-21-35-28.bpo-41627.sx2KN1.rst b/Misc/NEWS.d/next/Windows/2020-09-04-21-35-28.bpo-41627.sx2KN1.rst
new file mode 100644 (file)
index 0000000..043bd5e
--- /dev/null
@@ -0,0 +1,2 @@
+The user site directory for 32-bit now includes a ``-32`` suffix to
+distinguish it from the 64-bit interpreter's directory.