[Checkins] SVN: zc.buildout/trunk/ Bugs Fixed

Jim Fulton jim at zope.com
Thu Dec 7 14:02:57 EST 2006


Log message for revision 71489:
  Bugs Fixed
  ----------
  
  - Uninstall recipes weren't loaded correctly in cases where
    no parts in the (new) configuration used the recipe egg.
  

Changed:
  U   zc.buildout/trunk/CHANGES.txt
  U   zc.buildout/trunk/setup.py
  U   zc.buildout/trunk/src/zc/buildout/buildout.py
  U   zc.buildout/trunk/src/zc/buildout/tests.py

-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt	2006-12-07 18:54:31 UTC (rev 71488)
+++ zc.buildout/trunk/CHANGES.txt	2006-12-07 19:02:57 UTC (rev 71489)
@@ -20,7 +20,7 @@
 Change History
 **************
 
-1.0.0b15 (2006-12-07)
+1.0.0b16 (2006-12-07)
 =====================
 
 Feature Changes
@@ -39,6 +39,15 @@
   those parts are supposed to be installed, but the buildout was also
   building parts that those parts depended on.
 
+1.0.0b15 (2006-12-06)
+=====================
+
+Bugs Fixed
+----------
+
+- Uninstall recipes weren't loaded correctly in cases where
+  no parts in the (new) configuration used the recipe egg.
+
 1.0.0b14 (2006-12-05)
 =====================
 

Modified: zc.buildout/trunk/setup.py
===================================================================
--- zc.buildout/trunk/setup.py	2006-12-07 18:54:31 UTC (rev 71488)
+++ zc.buildout/trunk/setup.py	2006-12-07 19:02:57 UTC (rev 71489)
@@ -7,7 +7,7 @@
 name = "zc.buildout"
 setup(
     name = name,
-    version = "1.0.0b14",
+    version = "1.0.0b15",
     author = "Jim Fulton",
     author_email = "jim at zope.com",
     description = "System for managing development buildouts",

Modified: zc.buildout/trunk/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/buildout.py	2006-12-07 18:54:31 UTC (rev 71488)
+++ zc.buildout/trunk/src/zc/buildout/buildout.py	2006-12-07 19:02:57 UTC (rev 71489)
@@ -256,12 +256,11 @@
                 # run uinstall recipe
                 recipe, entry = _recipe(installed_part_options[part])
                 try:
-                    uninstaller = pkg_resources.load_entry_point(
-                        recipe, 'zc.buildout.uninstall', entry)
+                    uninstaller = _install_and_load(
+                        recipe, 'zc.buildout.uninstall', entry, self)
                     self._logger.info('Running uninstall recipe')
                     uninstaller(part, installed_part_options[part])
-                except (ImportError, pkg_resources.DistributionNotFound):
-                    # no uninstall recipe registered
+                except (ImportError, pkg_resources.DistributionNotFound), v:
                     pass
 
                 # remove created files and directories
@@ -624,6 +623,41 @@
     def __iter__(self):
         return iter(self._raw)
 
+
+def _install_and_load(spec, group, entry, buildout):
+    try:
+
+        req = pkg_resources.Requirement.parse(spec)
+
+        buildout_options = buildout['buildout']
+        if pkg_resources.working_set.find(req) is None:
+            if buildout_options['offline'] == 'true':
+                dest = None
+                path = [buildout_options['develop-eggs-directory'],
+                        buildout_options['eggs-directory'],
+                        ]
+            else:
+                dest = buildout_options['eggs-directory']
+                path = [buildout_options['develop-eggs-directory']]
+
+            zc.buildout.easy_install.install(
+                [spec], dest,
+                links=buildout._links,
+                index=buildout_options.get('index'),
+                path=path,
+                working_set=pkg_resources.working_set,
+                )
+
+        return pkg_resources.load_entry_point(
+            req.project_name, group, entry)
+
+    except Exception, v:
+        buildout._logger.log(
+            1,
+            "Could't load %s entry point %s\nfrom %s:\n%s.",
+            group, entry, spec, v)
+        raise
+
 class Options(UserDict.DictMixin):
 
     def __init__(self, buildout, section, data):
@@ -642,29 +676,8 @@
             return
         
         reqs, entry = _recipe(self._data)
-        req = pkg_resources.Requirement.parse(reqs)
         buildout = self.buildout
-        
-        if pkg_resources.working_set.find(req) is None:
-            offline = buildout['buildout']['offline'] == 'true'
-            if offline:
-                dest = None
-                path = [buildout['buildout']['develop-eggs-directory'],
-                        buildout['buildout']['eggs-directory'],
-                        ]
-            else:
-                dest = buildout['buildout']['eggs-directory']
-                path = [buildout['buildout']['develop-eggs-directory']]
-            zc.buildout.easy_install.install(
-                [reqs], dest,
-                links=buildout._links,
-                index=buildout['buildout'].get('index'),
-                path=path,
-                working_set=pkg_resources.working_set,
-                )
-            
-        recipe_class = pkg_resources.load_entry_point(
-            req.project_name, 'zc.buildout', entry)
+        recipe_class = _install_and_load(reqs, 'zc.buildout', entry, buildout)
 
         self.recipe = recipe_class(buildout, self.name, self)
         buildout._parts.append(self.name)

Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py	2006-12-07 18:54:31 UTC (rev 71488)
+++ zc.buildout/trunk/src/zc/buildout/tests.py	2006-12-07 19:02:57 UTC (rev 71489)
@@ -754,8 +754,80 @@
     define = X,Y
 
 """
+
+def uninstall_recipes_used_for_removal():
+    """
+Uninstall recipes need to be called when a part is removed too:
+
+    >>> mkdir("recipes")
+    >>> write("recipes", "setup.py",
+    ... '''
+    ... from setuptools import setup
+    ... setup(name='recipes',
+    ...       entry_points={
+    ...          'zc.buildout': ["demo=demo:Install"],
+    ...          'zc.buildout.uninstall': ["demo=demo:uninstall"],
+    ...          })
+    ... ''')
+
+    >>> write("recipes", "demo.py",
+    ... '''
+    ... class Install:
+    ...     def __init__(*args): pass
+    ...     def install(self):
+    ...         print 'installing'
+    ...         return ()
+    ... def uninstall(name, options): print 'uninstalling'
+    ... ''')
+
+    >>> write('buildout.cfg', '''
+    ... [buildout]
+    ... develop = recipes
+    ... parts = demo
+    ... [demo]
+    ... recipe = recipes:demo
+    ... ''')
+
+    >>> print system(join('bin', 'buildout')),
+    buildout: Develop: /tmp/tmpnTSVbq/_TEST_/sample-buildout/recipes
+    buildout: Installing demo
+    installing
+
+
+    >>> write('buildout.cfg', '''
+    ... [buildout]
+    ... develop = recipes
+    ... parts = demo
+    ... [demo]
+    ... recipe = recipes:demo
+    ... x = 1
+    ... ''')
+
+    >>> print system(join('bin', 'buildout')),
+    buildout: Develop: /sample-buildout/recipes
+    buildout: Uninstalling demo
+    buildout: Running uninstall recipe
+    uninstalling
+    buildout: Installing demo
+    installing
+
+
+    >>> write('buildout.cfg', '''
+    ... [buildout]
+    ... develop = recipes
+    ... parts = 
+    ... ''')
+
+    >>> print system(join('bin', 'buildout')),
+    buildout: Develop: /sample-buildout/recipes
+    buildout: Uninstalling demo
+    buildout: Running uninstall recipe
+    uninstalling
+
+"""
+
+######################################################################
     
-    
 def create_sample_eggs(test, executable=sys.executable):
     write = test.globs['write']
     dest = test.globs['sample_eggs']



More information about the Checkins mailing list