Commit a3acb0da authored by jim's avatar jim

Added a recipe update method.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@70561 62d5b8a3-27da-0310-9561-8e5933582275
parent 66e1e9ce
......@@ -28,7 +28,12 @@ Next Release
Feature Changes
---------------
Renamed the runsetup command to setup. (The old name still works.)
- Renamed the runsetup command to setup. (The old name still works.)
- Added a recipe update method. Now install is only called when a part
is installed for the first time, or after an uninstall. Otherwise,
update is called. For backward compatibility, recipes that don't
define update methiods are still supported.
1.0.0b9 (2006-10-02)
====================
......
......@@ -288,10 +288,21 @@ class Buildout(dict):
for part in reversed(installed_parts):
if part in install_parts:
old_options = installed_part_options[part].copy()
old_options.pop('__buildout_installed__')
installed_files = old_options.pop('__buildout_installed__')
new_options = self.get(part)
if old_options == new_options:
# The options are the same, but are all of the
# installed files still there? If not, we should
# reinstall.
if not installed_files:
continue
for f in installed_files.split('\n'):
if not os.path.exists(self._buildout_path(f)):
break
else:
continue
# output debugging info
for k in old_options:
if k not in new_options:
self._logger.debug("Part: %s, dropped option %s",
......@@ -305,6 +316,7 @@ class Buildout(dict):
if k not in old_options:
self._logger.debug("Part: %s, new option %s",
part, k)
elif not uninstall_missing:
continue
......@@ -316,17 +328,52 @@ class Buildout(dict):
# install new parts
for part in install_parts:
signature = self[part].pop('__buildout_signature__')
saved_options = self[part].copy()
if part in installed_parts:
self._logger.info('Updating %s', part)
old_options = installed_part_options[part]
old_installed_files = old_options['__buildout_installed__']
try:
update = recipes[part].update
except AttributeError:
update = recipes[part].install
self._logger.warning(
"The recipe for %s doesn't define an update "
"method. Using it's install method",
part)
try:
installed_files = update()
except:
installed_parts.remove(part)
self._uninstall(old_installed_files)
raise
if installed_files is None:
installed_files = old_installed_files.split('\n')
else:
self._logger.info('Installing %s', part)
installed_part_options[part] = self[part].copy()
del self[part]['__buildout_signature__']
installed_files = recipes[part].install() or ()
installed_files = recipes[part].install()
if installed_files is None:
self._logger.warning(
"The %s install returned None. A path or "
"iterable os paths should be returned.",
part)
installed_files = ()
if isinstance(installed_files, str):
installed_files = [installed_files]
installed_part_options[part]['__buildout_installed__'] = (
'\n'.join(installed_files)
)
installed_part_options[part] = saved_options
saved_options['__buildout_installed__'
] = '\n'.join(installed_files)
saved_options['__buildout_signature__'] = signature
if part not in installed_parts:
installed_parts.append(part)
finally:
installed_part_options['buildout']['parts'] = ' '.join(
[p for p in conf_parts if p in installed_parts]
......@@ -475,7 +522,9 @@ class Buildout(dict):
return self._buildout_path(self['buildout']['installed'])
def _uninstall(self, installed):
for f in installed.split():
for f in installed.split('\n'):
if not f:
continue
f = self._buildout_path(f)
if os.path.isdir(f):
shutil.rmtree(f)
......
This diff is collapsed.
......@@ -178,6 +178,8 @@ def test_comparing_saved_options_with_funny_characters():
... def install(self):
... open('t', 'w').write('t')
... return 't'
...
... update = install
... ''')
......@@ -214,7 +216,7 @@ uninstalling anything because the configuration hasn't changed.
>>> print system(buildout), # doctest: +ELLIPSIS
buildout: Develop: ...setup.py
buildout: Installing debug
buildout: Updating debug
"""
......@@ -277,22 +279,22 @@ Options:
<BLANKLINE>
-q
<BLANKLINE>
Deccreaae the level of verbosity. This option can be used multiple times.
Decrease the level of verbosity. This option can be used multiple times.
<BLANKLINE>
-c config_file
<BLANKLINE>
Specify the path to the buildout configuration file to be used.
This defaults to the file named"buildout.cfg" in the current
This defaults to the file named "buildout.cfg" in the current
working directory.
<BLANKLINE>
Assignments are of the form: section:option=value and are used to
provide configuration options that override those givem in the
provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode,
use buildout:offline=true.
<BLANKLINE>
Options and assignments can be interspersed.
<BLANKLINE>
Commmonds:
Commands:
<BLANKLINE>
install [parts]
<BLANKLINE>
......@@ -324,22 +326,22 @@ Options:
<BLANKLINE>
-q
<BLANKLINE>
Deccreaae the level of verbosity. This option can be used multiple times.
Decrease the level of verbosity. This option can be used multiple times.
<BLANKLINE>
-c config_file
<BLANKLINE>
Specify the path to the buildout configuration file to be used.
This defaults to the file named"buildout.cfg" in the current
This defaults to the file named "buildout.cfg" in the current
working directory.
<BLANKLINE>
Assignments are of the form: section:option=value and are used to
provide configuration options that override those givem in the
provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode,
use buildout:offline=true.
<BLANKLINE>
Options and assignments can be interspersed.
<BLANKLINE>
Commmonds:
Commands:
<BLANKLINE>
install [parts]
<BLANKLINE>
......
......@@ -44,6 +44,7 @@ zc.buildout used:
... for project in 'zc.buildout', 'setuptools':
... req = pkg_resources.Requirement.parse(project)
... print project, pkg_resources.working_set.find(req).version
... return ()
... """)
......
......@@ -8,6 +8,8 @@ To do
Change History
**************
Updated to work with zc.buildout 1.0.0b10.
1.0.0b1
=======
......
......@@ -38,6 +38,9 @@ around the egg recipe:
... for d in ws:
... print d
... print 'extra paths:', self.egg.extra_paths
... return ()
...
... update = install
... """)
Here we instantiated the egg recipe in the constructor, saving it in
......
......@@ -67,7 +67,7 @@ class Custom:
def install(self):
if self.buildout['buildout'].get('offline') == 'true':
return
return ()
options = self.options
distribution = options.get('eggs', self.name).strip()
build_ext = dict([
......@@ -80,3 +80,6 @@ class Custom:
self.links, self.index, options['executable'], [options['_e']],
)
return ()
update = install
......@@ -119,3 +119,6 @@ class Egg:
interpreter=options.get('interpreter'),
)
return ()
update = install
......@@ -2,6 +2,8 @@
Change History
**************
Updated to work with zc.buildout 1.0.0b10.
1.0.0b2
=======
......
......@@ -54,6 +54,8 @@ class TestRunner:
)),
)
update = install
arg_template = """[
'--test-path', %(TESTPATH)s,
]"""
......
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