]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133951: Remove lib64->lib symlink in venv creation (#137139)
authorCycloctane <Cycloctane@outlook.com>
Sat, 4 Oct 2025 13:55:17 +0000 (21:55 +0800)
committerGitHub <noreply@github.com>
Sat, 4 Oct 2025 13:55:17 +0000 (14:55 +0100)
* Remove lib64->lib symlink in venv directory

* fix test

* remove unused import

* add news

Lib/test/test_venv.py
Lib/venv/__init__.py
Misc/NEWS.d/next/Library/2025-07-27-17-03-17.gh-issue-133951.7kwt78.rst [new file with mode: 0644]

index 3c18c9c2900ad71dff25d23cf6bc1f8272d5b03b..d46b45e54370b1fa7c6299da1a2b1384f7ebff60 100644 (file)
@@ -12,7 +12,6 @@ import os.path
 import pathlib
 import re
 import shutil
-import struct
 import subprocess
 import sys
 import sysconfig
@@ -138,14 +137,9 @@ class BasicTest(BaseTest):
         self.isdir(self.bindir)
         self.isdir(self.include)
         self.isdir(*self.lib)
-        # Issue 21197
         p = self.get_env_file('lib64')
-        conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and
-                      (sys.platform != 'darwin'))
-        if conditions:
-            self.assertTrue(os.path.islink(p))
-        else:
-            self.assertFalse(os.path.exists(p))
+        if os.path.exists(p):
+            self.assertFalse(os.path.islink(p))
         data = self.get_text_file_contents('pyvenv.cfg')
         executable = sys._base_executable
         path = os.path.dirname(executable)
index dc9c5991df7e1c83c1037e72e30d91b328014db9..e5addcc393a1b913cdbb3425d5cad32674ab02fa 100644 (file)
@@ -174,6 +174,7 @@ class EnvBuilder:
         context.python_exe = exename
         binpath = self._venv_path(env_dir, 'scripts')
         libpath = self._venv_path(env_dir, 'purelib')
+        platlibpath = self._venv_path(env_dir, 'platlib')
 
         # PEP 405 says venvs should create a local include directory.
         # See https://peps.python.org/pep-0405/#include-files
@@ -191,12 +192,8 @@ class EnvBuilder:
         create_if_needed(incpath)
         context.lib_path = libpath
         create_if_needed(libpath)
-        # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
-        if ((sys.maxsize > 2**32) and (os.name == 'posix') and
-            (sys.platform != 'darwin')):
-            link_path = os.path.join(env_dir, 'lib64')
-            if not os.path.exists(link_path):   # Issue #21643
-                os.symlink('lib', link_path)
+        context.platlib_path = platlibpath
+        create_if_needed(platlibpath)
         context.bin_path = binpath
         context.bin_name = os.path.relpath(binpath, env_dir)
         context.env_exe = os.path.join(binpath, exename)
diff --git a/Misc/NEWS.d/next/Library/2025-07-27-17-03-17.gh-issue-133951.7kwt78.rst b/Misc/NEWS.d/next/Library/2025-07-27-17-03-17.gh-issue-133951.7kwt78.rst
new file mode 100644 (file)
index 0000000..dfda8e8
--- /dev/null
@@ -0,0 +1,2 @@
+Remove lib64-lib symlink creation when creating new virtual environments in
+:mod:`venv` module