Commit 418893a9 authored by Jim Fulton's avatar Jim Fulton

Bugs Fixed

----------

- Uninstall recipes weren't loaded correctly in cases where
  no parts in the (new) configuration used the recipe egg.
parent ac702c5f
...@@ -20,7 +20,7 @@ priorities include: ...@@ -20,7 +20,7 @@ priorities include:
Change History Change History
************** **************
1.0.0b15 (2006-12-07) 1.0.0b16 (2006-12-07)
===================== =====================
Feature Changes Feature Changes
...@@ -39,6 +39,15 @@ Bugs Fixed ...@@ -39,6 +39,15 @@ Bugs Fixed
those parts are supposed to be installed, but the buildout was also those parts are supposed to be installed, but the buildout was also
building parts that those parts depended on. 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) 1.0.0b14 (2006-12-05)
===================== =====================
......
...@@ -7,7 +7,7 @@ def read(*rnames): ...@@ -7,7 +7,7 @@ def read(*rnames):
name = "zc.buildout" name = "zc.buildout"
setup( setup(
name = name, name = name,
version = "1.0.0b14", version = "1.0.0b15",
author = "Jim Fulton", author = "Jim Fulton",
author_email = "jim@zope.com", author_email = "jim@zope.com",
description = "System for managing development buildouts", description = "System for managing development buildouts",
......
...@@ -256,12 +256,11 @@ class Buildout(UserDict.DictMixin): ...@@ -256,12 +256,11 @@ class Buildout(UserDict.DictMixin):
# run uinstall recipe # run uinstall recipe
recipe, entry = _recipe(installed_part_options[part]) recipe, entry = _recipe(installed_part_options[part])
try: try:
uninstaller = pkg_resources.load_entry_point( uninstaller = _install_and_load(
recipe, 'zc.buildout.uninstall', entry) recipe, 'zc.buildout.uninstall', entry, self)
self._logger.info('Running uninstall recipe') self._logger.info('Running uninstall recipe')
uninstaller(part, installed_part_options[part]) uninstaller(part, installed_part_options[part])
except (ImportError, pkg_resources.DistributionNotFound): except (ImportError, pkg_resources.DistributionNotFound), v:
# no uninstall recipe registered
pass pass
# remove created files and directories # remove created files and directories
...@@ -624,6 +623,41 @@ class Buildout(UserDict.DictMixin): ...@@ -624,6 +623,41 @@ class Buildout(UserDict.DictMixin):
def __iter__(self): def __iter__(self):
return iter(self._raw) 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): class Options(UserDict.DictMixin):
def __init__(self, buildout, section, data): def __init__(self, buildout, section, data):
...@@ -642,29 +676,8 @@ class Options(UserDict.DictMixin): ...@@ -642,29 +676,8 @@ class Options(UserDict.DictMixin):
return return
reqs, entry = _recipe(self._data) reqs, entry = _recipe(self._data)
req = pkg_resources.Requirement.parse(reqs)
buildout = self.buildout buildout = self.buildout
recipe_class = _install_and_load(reqs, 'zc.buildout', entry, 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)
self.recipe = recipe_class(buildout, self.name, self) self.recipe = recipe_class(buildout, self.name, self)
buildout._parts.append(self.name) buildout._parts.append(self.name)
......
...@@ -754,7 +754,79 @@ existing setup.cfg: ...@@ -754,7 +754,79 @@ existing setup.cfg:
define = X,Y 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): def create_sample_eggs(test, executable=sys.executable):
write = test.globs['write'] write = test.globs['write']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment