1. Jason R. Coombs
  2. zc.buildout-bootstrap

Commits

wic...@62d5b8a3-27da-0310-9561-8e5933582275  committed f79574d

Handle systems with pkg_resources but without setuptools (I am looking at you Ubuntu.. grrr). Fixes LP#410528

  • Participants
  • Parent commits aa35481
  • Branches default

Comments (0)

Files changed (2)

File bootstrap.py

View file
  • Ignore whitespace
 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 = {}
                              ).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):

File newbootstrap.py

View file
  • Ignore whitespace
 
 
 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')
     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: