Skip to content

Commit 512dc82

Browse files
Revert "pythongh-133951: Remove lib64->lib symlink in venv creation (python#137139)"
This reverts commit a7a4855.
1 parent 0b21682 commit 512dc82

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Lib/test/test_venv.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pathlib
1313
import re
1414
import shutil
15+
import struct
1516
import subprocess
1617
import sys
1718
import sysconfig
@@ -137,9 +138,14 @@ def _check_output_of_default_create(self):
137138
self.isdir(self.bindir)
138139
self.isdir(self.include)
139140
self.isdir(*self.lib)
141+
# Issue 21197
140142
p = self.get_env_file('lib64')
141-
if os.path.exists(p):
142-
self.assertFalse(os.path.islink(p))
143+
conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and
144+
(sys.platform != 'darwin'))
145+
if conditions:
146+
self.assertTrue(os.path.islink(p))
147+
else:
148+
self.assertFalse(os.path.exists(p))
143149
data = self.get_text_file_contents('pyvenv.cfg')
144150
executable = sys._base_executable
145151
path = os.path.dirname(executable)

Lib/venv/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ def create_if_needed(d):
174174
context.python_exe = exename
175175
binpath = self._venv_path(env_dir, 'scripts')
176176
libpath = self._venv_path(env_dir, 'purelib')
177-
platlibpath = self._venv_path(env_dir, 'platlib')
178177

179178
# PEP 405 says venvs should create a local include directory.
180179
# See https://peps.python.org/pep-0405/#include-files
@@ -192,8 +191,12 @@ def create_if_needed(d):
192191
create_if_needed(incpath)
193192
context.lib_path = libpath
194193
create_if_needed(libpath)
195-
context.platlib_path = platlibpath
196-
create_if_needed(platlibpath)
194+
# Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
195+
if ((sys.maxsize > 2**32) and (os.name == 'posix') and
196+
(sys.platform != 'darwin')):
197+
link_path = os.path.join(env_dir, 'lib64')
198+
if not os.path.exists(link_path): # Issue #21643
199+
os.symlink('lib', link_path)
197200
context.bin_path = binpath
198201
context.bin_name = os.path.relpath(binpath, env_dir)
199202
context.env_exe = os.path.join(binpath, exename)

Misc/NEWS.d/next/Library/2025-07-27-17-03-17.gh-issue-133951.7kwt78.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)