]> granicus.if.org Git - python/commitdiff
Issue #21643: Updated test and fixed logic bug in lib64 symlink creation.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 3 Jun 2014 15:47:51 +0000 (16:47 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 3 Jun 2014 15:47:51 +0000 (16:47 +0100)
Lib/test/test_venv.py
Lib/venv/__init__.py

index e13cd8cf9890c7cb35222c8112765f6f2f0ea448..8dfff519aa558562d16eb7ecda52713a2bd5ff24 100644 (file)
@@ -203,17 +203,22 @@ class BasicTest(BaseTest):
         """
         Test upgrading an existing environment directory.
         """
-        builder = venv.EnvBuilder(upgrade=True)
-        self.run_with_capture(builder.create, self.env_dir)
-        self.isdir(self.bindir)
-        self.isdir(self.include)
-        self.isdir(*self.lib)
-        fn = self.get_env_file(self.bindir, self.exe)
-        if not os.path.exists(fn):  # diagnostics for Windows buildbot failures
-            bd = self.get_env_file(self.bindir)
-            print('Contents of %r:' % bd)
-            print('    %r' % os.listdir(bd))
-        self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn)
+        # See Issue #21643: the loop needs to run twice to ensure
+        # that everything works on the upgrade (the first run just creates
+        # the venv).
+        for upgrade in (False, True):
+            builder = venv.EnvBuilder(upgrade=upgrade)
+            self.run_with_capture(builder.create, self.env_dir)
+            self.isdir(self.bindir)
+            self.isdir(self.include)
+            self.isdir(*self.lib)
+            fn = self.get_env_file(self.bindir, self.exe)
+            if not os.path.exists(fn):
+                # diagnostics for Windows buildbot failures
+                bd = self.get_env_file(self.bindir)
+                print('Contents of %r:' % bd)
+                print('    %r' % os.listdir(bd))
+            self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn)
 
     def test_isolation(self):
         """
index 252bffbd7be1d80b1007937d6a20d7036d268f78..c258b1c05a495b03eb14eac3af00400b653b97c8 100644 (file)
@@ -30,7 +30,6 @@ optional arguments:
 import logging
 import os
 import shutil
-import struct
 import subprocess
 import sys
 import types
@@ -140,11 +139,12 @@ class EnvBuilder:
         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
+        if ((sys.maxsize > 2**32) 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)
+            if not os.path.exists(link_path):   # Issue #21643
+                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)