Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e53f8d

Browse files
committed
Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX.
1 parent a0d1073 commit 1e53f8d

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

Lib/test/test_venv.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import os.path
1111
import shutil
12+
import struct
1213
import subprocess
1314
import sys
1415
import tempfile
@@ -87,6 +88,14 @@ def test_defaults(self):
8788
self.isdir(self.bindir)
8889
self.isdir(self.include)
8990
self.isdir(*self.lib)
91+
# Issue 21197
92+
p = self.get_env_file('lib64')
93+
conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and
94+
(sys.platform != 'darwin'))
95+
if conditions:
96+
self.assertTrue(os.path.islink(p))
97+
else:
98+
self.assertFalse(os.path.exists(p))
9099
data = self.get_text_file_contents('pyvenv.cfg')
91100
if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__'
92101
in os.environ):

Lib/venv/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Virtual environment (venv) package for Python. Based on PEP 405.
33
4-
Copyright (C) 2011-2012 Vinay Sajip.
4+
Copyright (C) 2011-2014 Vinay Sajip.
55
Licensed to the PSF under a contributor agreement.
66
77
usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear]
@@ -30,6 +30,7 @@
3030
import logging
3131
import os
3232
import shutil
33+
import struct
3334
import subprocess
3435
import sys
3536
import types
@@ -132,10 +133,18 @@ def create_if_needed(d):
132133
else:
133134
binname = 'bin'
134135
incpath = 'include'
135-
libpath = os.path.join(env_dir, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages')
136+
libpath = os.path.join(env_dir, 'lib',
137+
'python%d.%d' % sys.version_info[:2],
138+
'site-packages')
136139
context.inc_path = path = os.path.join(env_dir, incpath)
137140
create_if_needed(path)
138141
create_if_needed(libpath)
142+
# Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
143+
if ((struct.calcsize('P') == 8) and (os.name == 'posix') and
144+
(sys.platform != 'darwin')):
145+
p = os.path.join(env_dir, 'lib')
146+
link_path = os.path.join(env_dir, 'lib64')
147+
os.symlink(p, link_path)
139148
context.bin_path = binpath = os.path.join(env_dir, binname)
140149
context.bin_name = binname
141150
context.env_exe = os.path.join(binpath, exename)

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Core and Builtins
4141
Library
4242
-------
4343

44+
- Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX.
45+
4446
- Issue #17498: Some SMTP servers disconnect after certain errors, violating
4547
strict RFC conformance. Instead of losing the error code when we issue the
4648
subsequent RSET, smtplib now returns the error code and defers raising the

0 commit comments

Comments
 (0)