[Python-checkins] r51777 - sandbox/trunk/setuptools/ez_setup.py

phillip.eby python-checkins at python.org
Wed Sep 6 20:10:14 CEST 2006


Author: phillip.eby
Date: Wed Sep  6 20:10:13 2006
New Revision: 51777

Modified:
   sandbox/trunk/setuptools/ez_setup.py
Log:
Support setuptools .egg being in current directory when bootstrapping on 
an offline machine.  Output what version/location is conflicting when a 
newer version of setuptools is requested.


Modified: sandbox/trunk/setuptools/ez_setup.py
==============================================================================
--- sandbox/trunk/setuptools/ez_setup.py	(original)
+++ sandbox/trunk/setuptools/ez_setup.py	Wed Sep  6 20:10:13 2006
@@ -71,13 +71,13 @@
     try:
         pkg_resources.require("setuptools>="+version)
 
-    except pkg_resources.VersionConflict:
+    except pkg_resources.VersionConflict, e:
         # XXX could we install in a subprocess here?
         print >>sys.stderr, (
             "The required version of setuptools (>=%s) is not available, and\n"
             "can't be installed while this script is running. Please install\n"
-            " a more recent version first."
-        ) % version
+            " a more recent version first.\n\n(Currently using %r)"
+        ) % (version, e.args[0])
         sys.exit(2)
 
 def download_setuptools(
@@ -133,15 +133,15 @@
     try:
         import setuptools
     except ImportError:
-        import tempfile, shutil
-        tmpdir = tempfile.mkdtemp(prefix="easy_install-")
+        egg = None
         try:
-            egg = download_setuptools(version, to_dir=tmpdir, delay=0)
+            egg = download_setuptools(version, delay=0)
             sys.path.insert(0,egg)
             from setuptools.command.easy_install import main
             return main(list(argv)+[egg])   # we're done here
         finally:
-            shutil.rmtree(tmpdir)
+            if egg and os.path.exists(egg):
+                os.unlink(egg)
     else:
         if setuptools.__version__ == '0.0.1':
             # tell the user to uninstall obsolete version


More information about the Python-checkins mailing list