[Checkins] SVN: zc.buildout/trunk/ Handle systems with pkg_resources but without setuptools (I am looking at you Ubuntu.. grrr). Fixes LP#410528

Wichert Akkerman wichert at wiggy.net
Wed Jun 23 08:50:35 EDT 2010


Log message for revision 113780:
  Handle systems with pkg_resources but without setuptools (I am looking at you Ubuntu.. grrr). Fixes LP#410528

Changed:
  U   zc.buildout/trunk/CHANGES.txt
  U   zc.buildout/trunk/bootstrap/bootstrap.py
  U   zc.buildout/trunk/bootstrap/newbootstrap.py

-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt	2010-06-23 08:09:43 UTC (rev 113779)
+++ zc.buildout/trunk/CHANGES.txt	2010-06-23 12:50:34 UTC (rev 113780)
@@ -42,6 +42,10 @@
   * The buildout script generated by bootstrap honors more of the settings
     in the designated configuration file (e.g., buildout.cfg).
 
+  * Correcly handle systems where pkg_resources is present but the rest of
+    setuptools is missing (like Ubuntu installs).
+    https://bugs.launchpad.net/zc.buildout/+bug/410528
+
 - You can develop zc.buildout using Distribute instead of Setuptools.  Use
   the --distribute option on the dev.py script.  (Releases should be tested
   with both Distribute and Setuptools.)  The tests for zc.buildout pass

Modified: zc.buildout/trunk/bootstrap/bootstrap.py
===================================================================
--- zc.buildout/trunk/bootstrap/bootstrap.py	2010-06-23 08:09:43 UTC (rev 113779)
+++ zc.buildout/trunk/bootstrap/bootstrap.py	2010-06-23 12:50:34 UTC (rev 113780)
@@ -53,11 +53,10 @@
 USE_DISTRIBUTE = options.distribute
 args = args + ['bootstrap']
 
-to_reload = False
 try:
     import pkg_resources
+    import setuptools
     if not hasattr(pkg_resources, '_distribute'):
-        to_reload = True
         raise ImportError
 except ImportError:
     ez = {}
@@ -70,10 +69,8 @@
                              ).read() in ez
         ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
 
-    if to_reload:
-        reload(pkg_resources)
-    else:
-        import pkg_resources
+    reload(sys.modules['pkg_resources'])
+    import pkg_resources
 
 if sys.platform == 'win32':
     def quote(c):

Modified: zc.buildout/trunk/bootstrap/newbootstrap.py
===================================================================
--- zc.buildout/trunk/bootstrap/newbootstrap.py	2010-06-23 08:09:43 UTC (rev 113779)
+++ zc.buildout/trunk/bootstrap/newbootstrap.py	2010-06-23 12:50:34 UTC (rev 113780)
@@ -134,12 +134,10 @@
 
 
 try:
-    to_reload = False
     import pkg_resources
-    to_reload = True
+    import setuptools # A flag.  Sometimes pkg_resources is installed alone.
     if not hasattr(pkg_resources, '_distribute'):
         raise ImportError
-    import setuptools # A flag.  Sometimes pkg_resources is installed alone.
 except ImportError:
     ez_code = urllib2.urlopen(
         options.setup_source).read().replace('\r\n', '\n')
@@ -151,10 +149,8 @@
     if options.use_distribute:
         setup_args['no_fake'] = True
     ez['use_setuptools'](**setup_args)
-    if to_reload:
-        reload(pkg_resources)
-    else:
-        import pkg_resources
+    reload(sys.modules['pkg_resources'])
+    import pkg_resources
     # This does not (always?) update the default working set.  We will
     # do it.
     for path in sys.path:



More information about the checkins mailing list