Skip to content

Commit a7a4855

Browse files
authored
gh-133951: Remove lib64->lib symlink in venv creation (#137139)
* Remove lib64->lib symlink in venv directory * fix test * remove unused import * add news
1 parent 8d17d79 commit a7a4855

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

Lib/test/test_venv.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import pathlib
1313
import re
1414
import shutil
15-
import struct
1615
import subprocess
1716
import sys
1817
import sysconfig
@@ -138,14 +137,9 @@ def _check_output_of_default_create(self):
138137
self.isdir(self.bindir)
139138
self.isdir(self.include)
140139
self.isdir(*self.lib)
141-
# Issue 21197
142140
p = self.get_env_file('lib64')
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))
141+
if os.path.exists(p):
142+
self.assertFalse(os.path.islink(p))
149143
data = self.get_text_file_contents('pyvenv.cfg')
150144
executable = sys._base_executable
151145
path = os.path.dirname(executable)

Lib/venv/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ 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')
177178

178179
# PEP 405 says venvs should create a local include directory.
179180
# See https://peps.python.org/pep-0405/#include-files
@@ -191,12 +192,8 @@ def create_if_needed(d):
191192
create_if_needed(incpath)
192193
context.lib_path = libpath
193194
create_if_needed(libpath)
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)
195+
context.platlib_path = platlibpath
196+
create_if_needed(platlibpath)
200197
context.bin_path = binpath
201198
context.bin_name = os.path.relpath(binpath, env_dir)
202199
context.env_exe = os.path.join(binpath, exename)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove lib64-lib symlink creation when creating new virtual environments in
2+
:mod:`venv` module

0 commit comments

Comments
 (0)