[Python-checkins] cpython (merge 3.4 -> default): Closes #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX.

vinay.sajip python-checkins at python.org
Tue Apr 15 14:56:51 CEST 2014


http://hg.python.org/cpython/rev/947515cc8957
changeset:   90320:947515cc8957
parent:      90316:bf65e7db066d
parent:      90319:4c65f8641d89
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Tue Apr 15 13:56:36 2014 +0100
summary:
  Closes #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX.

files:
  Lib/test/test_venv.py |   9 +++++++++
  Lib/venv/__init__.py  |  13 +++++++++++--
  Misc/NEWS             |   2 ++
  3 files changed, 22 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -9,6 +9,7 @@
 import os
 import os.path
 import shutil
+import struct
 import subprocess
 import sys
 import tempfile
@@ -87,6 +88,14 @@
         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))
         data = self.get_text_file_contents('pyvenv.cfg')
         if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__'
                                          in os.environ):
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -1,7 +1,7 @@
 """
 Virtual environment (venv) package for Python. Based on PEP 405.
 
-Copyright (C) 2011-2012 Vinay Sajip.
+Copyright (C) 2011-2014 Vinay Sajip.
 Licensed to the PSF under a contributor agreement.
 
 usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear]
@@ -30,6 +30,7 @@
 import logging
 import os
 import shutil
+import struct
 import subprocess
 import sys
 import types
@@ -132,10 +133,18 @@
         else:
             binname = 'bin'
             incpath = 'include'
-            libpath = os.path.join(env_dir, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages')
+            libpath = os.path.join(env_dir, 'lib',
+                                   'python%d.%d' % sys.version_info[:2],
+                                   'site-packages')
         context.inc_path = path = os.path.join(env_dir, incpath)
         create_if_needed(path)
         create_if_needed(libpath)
+        # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
+        if ((struct.calcsize('P') == 8) and (os.name == 'posix') and
+            (sys.platform != 'darwin')):
+            p = os.path.join(env_dir, 'lib')
+            link_path = os.path.join(env_dir, 'lib64')
+            os.symlink(p, link_path)
         context.bin_path = binpath = os.path.join(env_dir, binname)
         context.bin_name = binname
         context.env_exe = os.path.join(binpath, exename)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -46,6 +46,8 @@
 Library
 -------
 
+- Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX.
+
 - Issue #17498: Some SMTP servers disconnect after certain errors, violating
   strict RFC conformance.  Instead of losing the error code when we issue the
   subsequent RSET, smtplib now returns the error code and defers raising the

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list