Commit b668a6cd authored by Julien Muchembled's avatar Julien Muchembled

New Options.barrier() to set a default requirement for not-yet processed parts

parent dffdeffc
...@@ -375,6 +375,7 @@ class Buildout(DictMixin): ...@@ -375,6 +375,7 @@ class Buildout(DictMixin):
self._parts = [] self._parts = []
self._initializing = [] self._initializing = []
self._signature_cache = {} self._signature_cache = {}
self._default_requirement = None
# provide some defaults before options are parsed # provide some defaults before options are parsed
# because while parsing options those attributes might be # because while parsing options those attributes might be
...@@ -1416,6 +1417,8 @@ class Options(DictMixin): ...@@ -1416,6 +1417,8 @@ class Options(DictMixin):
if '<' in self._raw: if '<' in self._raw:
self._raw = self._do_extend_raw(name, self._raw, []) self._raw = self._do_extend_raw(name, self._raw, [])
default = self.buildout._default_requirement
# force substitutions # force substitutions
for k, v in sorted(self._raw.items()): for k, v in sorted(self._raw.items()):
if '${' in v: if '${' in v:
...@@ -1425,6 +1428,8 @@ class Options(DictMixin): ...@@ -1425,6 +1428,8 @@ class Options(DictMixin):
return # buildout section can never be a part return # buildout section can never be a part
if self.get('recipe'): if self.get('recipe'):
if default:
self.depends.add(default)
self.recipe = self.buildout.initialize(self, *_recipe(self._data)) self.recipe = self.buildout.initialize(self, *_recipe(self._data))
self.buildout._parts.append(name) self.buildout._parts.append(name)
...@@ -1649,6 +1654,19 @@ class Options(DictMixin): ...@@ -1649,6 +1654,19 @@ class Options(DictMixin):
self.name) self.name)
return self._created return self._created
def barrier(self):
"""Set self as a default requirement for not-yet processed parts
This method must be called if this part may alter the processing
of other parts in any way, like modifying environment variables.
In other words, it sets an implicit dependency for these parts.
"""
buildout = self.buildout
if not buildout._initializing:
raise zc.buildout.UserError(
"Options.barrier() shall only be used during initialization")
buildout._default_requirement = self.name
def __repr__(self): def __repr__(self):
return repr(dict(self)) return repr(dict(self))
......
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