Commit 9a2c05ac authored by Jim Fulton's avatar Jim Fulton

Added an upload entry point for extensions.

Also fixed some spurious failures in the bootstrap test.
parent 522d9598
Change History Change History
************** **************
1.2.2 (unreleased) 1.2.2 (2009-06-19)
================== ==================
- Better Windows compatibility in test infrastructure. - Better Windows compatibility in test infrastructure.
...@@ -16,6 +16,8 @@ Change History ...@@ -16,6 +16,8 @@ Change History
- fixed usage of 'relative_paths' keyword parameter on Windows - fixed usage of 'relative_paths' keyword parameter on Windows
- Added an unload entry point for extensions.
1.2.1 (2009-03-18) 1.2.1 (2009-03-18)
================== ==================
......
...@@ -59,12 +59,7 @@ Let's try with an unknown version:: ...@@ -59,12 +59,7 @@ Let's try with an unknown version::
X X
No local packages or download links found for zc.buildout==UNKNOWN No local packages or download links found for zc.buildout==UNKNOWN
error: Could not find suitable distribution for Requirement.parse('zc.buildout==UNKNOWN') error: Could not find suitable distribution for Requirement.parse('zc.buildout==UNKNOWN')
Traceback (most recent call last): ...
File "bootstrap.py", line 78, in <module>
) == 0
AssertionError
<BLANKLINE>
X
Now let's try with `1.1.2`, which happens to exist:: Now let's try with `1.1.2`, which happens to exist::
......
...@@ -506,6 +506,8 @@ class Buildout(UserDict.DictMixin): ...@@ -506,6 +506,8 @@ class Buildout(UserDict.DictMixin):
elif (not installed_parts) and installed_exists: elif (not installed_parts) and installed_exists:
os.remove(self['buildout']['installed']) os.remove(self['buildout']['installed'])
self._unload_extensions()
def _update_installed(self, **buildout_options): def _update_installed(self, **buildout_options):
installed = self['buildout']['installed'] installed = self['buildout']['installed']
f = open(installed, 'a') f = open(installed, 'a')
...@@ -533,7 +535,6 @@ class Buildout(UserDict.DictMixin): ...@@ -533,7 +535,6 @@ class Buildout(UserDict.DictMixin):
self._uninstall( self._uninstall(
installed_part_options[part]['__buildout_installed__']) installed_part_options[part]['__buildout_installed__'])
def _setup_directories(self): def _setup_directories(self):
__doing__ = 'Setting up buildout directories' __doing__ = 'Setting up buildout directories'
...@@ -564,7 +565,8 @@ class Buildout(UserDict.DictMixin): ...@@ -564,7 +565,8 @@ class Buildout(UserDict.DictMixin):
setup = self._buildout_path(setup) setup = self._buildout_path(setup)
files = glob.glob(setup) files = glob.glob(setup)
if not files: if not files:
self._logger.warn("Couldn't develop %r (not found)", setup) self._logger.warn("Couldn't develop %r (not found)",
setup)
else: else:
files.sort() files.sort()
for setup in files: for setup in files:
...@@ -831,6 +833,14 @@ class Buildout(UserDict.DictMixin): ...@@ -831,6 +833,14 @@ class Buildout(UserDict.DictMixin):
for ep in pkg_resources.iter_entry_points('zc.buildout.extension'): for ep in pkg_resources.iter_entry_points('zc.buildout.extension'):
ep.load()(self) ep.load()(self)
def _unload_extensions(self):
__doing__ = 'Unloading extensions.'
specs = self['buildout'].get('extensions', '').split()
if specs:
for ep in pkg_resources.iter_entry_points(
'zc.buildout.unloadextension'):
ep.load()(self)
def setup(self, args): def setup(self, args):
if not args: if not args:
raise zc.buildout.UserError( raise zc.buildout.UserError(
......
...@@ -2368,15 +2368,17 @@ parts: ...@@ -2368,15 +2368,17 @@ parts:
Extensions Extensions
---------- ----------
An **experimental** feature allows code to be loaded and run after A feature allows code to be loaded and run after
configuration files have been read but before the buildout has begun configuration files have been read but before the buildout has begun
any processing. The intent is to allow special plugins such as any processing. The intent is to allow special plugins such as
urllib2 request handlers to be loaded. urllib2 request handlers to be loaded.
To load an extension, we use the extensions option and list one or To load an extension, we use the extensions option and list one or
more distribution requirements, on separate lines. The distributions more distribution requirements, on separate lines. The distributions
named will be loaded and any zc.buildout.extensions entry points found named will be loaded and any ``zc.buildout.extension`` entry points found
will be called with the buildout as an argument. will be called with the buildout as an argument. When buildout
finishes processing, any ``zc.buildout.unloadextension`` entry points
found will be called with the buildout as an argument.
Let's create a sample extension in our sample buildout created in the Let's create a sample extension in our sample buildout created in the
previous section: previous section:
...@@ -2387,6 +2389,8 @@ previous section: ...@@ -2387,6 +2389,8 @@ previous section:
... """ ... """
... def ext(buildout): ... def ext(buildout):
... print 'ext', list(buildout) ... print 'ext', list(buildout)
... def unload(buildout):
... print 'unload', list(buildout)
... """) ... """)
>>> write(sample_bootstrapped, 'demo', 'setup.py', >>> write(sample_bootstrapped, 'demo', 'setup.py',
...@@ -2395,7 +2399,10 @@ previous section: ...@@ -2395,7 +2399,10 @@ previous section:
... ...
... setup( ... setup(
... name = "demo", ... name = "demo",
... entry_points = {'zc.buildout.extension': ['ext = demo:ext']}, ... entry_points = {
... 'zc.buildout.extension': ['ext = demo:ext'],
... 'zc.buildout.unloadextension': ['ext = demo:unload'],
... },
... ) ... )
... """) ... """)
...@@ -2436,6 +2443,7 @@ We see that our extension is loaded and executed: ...@@ -2436,6 +2443,7 @@ We see that our extension is loaded and executed:
>>> print system(os.path.join(sample_bootstrapped, 'bin', 'buildout')), >>> print system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
ext ['buildout'] ext ['buildout']
Develop: '/sample-bootstrapped/demo' Develop: '/sample-bootstrapped/demo'
unload ['buildout']
Allow hosts Allow hosts
----------- -----------
......
...@@ -2895,6 +2895,7 @@ def test_suite(): ...@@ -2895,6 +2895,7 @@ def test_suite():
zc.buildout.testing.normalize_endings, zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_script, zc.buildout.testing.normalize_script,
normalize_bang, normalize_bang,
(re.compile('Downloading.*setuptools.*egg\n'), ''),
]), ]),
)) ))
......
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