Commit 9521ac53 authored by Jason Madden's avatar Jason Madden

Always detect missing extras, and let buildout exit cleanly if we find them.

Also add the required changes to zc.recipe.egg.
parent 5df83961
...@@ -736,20 +736,29 @@ class Installer(object): ...@@ -736,20 +736,29 @@ class Installer(object):
pkg_resources.VersionConflict(dist, req), ws) pkg_resources.VersionConflict(dist, req), ws)
best[req.key] = dist best[req.key] = dist
if self._allow_unknown_extras:
missing_requested = sorted( missing_requested = sorted(
set(req.extras) - set(dist.extras) set(req.extras) - set(dist.extras)
)
for missing in missing_requested:
logger.warning(
'%s does not provide the extra \'%s\'',
dist, missing
) )
for missing in missing_requested:
logger.warning( if missing_requested:
'%s does not provide the extra \'%s\'', if not self._allow_unknown_extras:
dist, missing raise zc.buildout.UserError(
"Couldn't find the required extras. Add 'allow-unknown-extras=true' "
"to the [buildout] configuration if this is acceptable."
) )
extra_requirements = sorted( extra_requirements = sorted(
set(dist.extras) & set(req.extras) set(dist.extras) & set(req.extras)
) )
else: else:
extra_requirements = dist.requires(req.extras)[::-1] extra_requirements = dist.requires(req.extras)[::-1]
for extra_requirement in extra_requirements: for extra_requirement in extra_requirements:
self._requirements_and_constraints.append( self._requirements_and_constraints.append(
"Requirement of %s: %s" % ( "Requirement of %s: %s" % (
......
...@@ -225,7 +225,7 @@ is an error. ...@@ -225,7 +225,7 @@ is an error.
... index=link_server+'index/') ... index=link_server+'index/')
Traceback (most recent call last): Traceback (most recent call last):
... ...
UnknownExtra: demo 0.3 has no such extra feature 'unknown_extra' UserError: Couldn't find the required extras. Add 'allow-unknown-extras=true' to the [buildout] configuration if this is acceptable.
We can pass the ``allow_unknown_extras`` argument to force the We can pass the ``allow_unknown_extras`` argument to force the
installation to proceed. installation to proceed.
......
...@@ -3730,9 +3730,7 @@ def test_suite(): ...@@ -3730,9 +3730,7 @@ def test_suite():
(re.compile(r'\\[\\]?'), '/'), (re.compile(r'\\[\\]?'), '/'),
(re.compile('(\n?)- ([a-zA-Z_.-]+)\n- \\2.exe\n'), (re.compile('(\n?)- ([a-zA-Z_.-]+)\n- \\2.exe\n'),
'\\1- \\2\n'), '\\1- \\2\n'),
(re.compile(r'^(\w+\.)*(UnknownExtra: )'), ]+(sys.version_info < (2, 5) and [
'\2'),
]+(sys.version_info < (2, 5) and [
(re.compile('.*No module named runpy.*', re.S), ''), (re.compile('.*No module named runpy.*', re.S), ''),
(re.compile('.*usage: pdb.py scriptfile .*', re.S), ''), (re.compile('.*usage: pdb.py scriptfile .*', re.S), ''),
(re.compile('.*Error: what does not exist.*', re.S), ''), (re.compile('.*Error: what does not exist.*', re.S), ''),
......
...@@ -23,6 +23,8 @@ import re ...@@ -23,6 +23,8 @@ import re
import sys import sys
import zc.buildout.easy_install import zc.buildout.easy_install
from zc.buildout.buildout import bool_option
class Eggs(object): class Eggs(object):
...@@ -82,6 +84,7 @@ class Eggs(object): ...@@ -82,6 +84,7 @@ class Eggs(object):
links=self.links, links=self.links,
index=self.index, index=self.index,
allow_hosts=self.allow_hosts, allow_hosts=self.allow_hosts,
allow_unknown_extras=bool_option(buildout['buildout'], 'allow-unknown-extras')
) )
return orig_distributions, ws return orig_distributions, ws
...@@ -127,6 +130,7 @@ class Eggs(object): ...@@ -127,6 +130,7 @@ class Eggs(object):
links=(), links=(),
index=None, index=None,
allow_hosts=('*',), allow_hosts=('*',),
allow_unknown_extras=False,
): ):
"""Helper function to build a working set. """Helper function to build a working set.
...@@ -145,6 +149,7 @@ class Eggs(object): ...@@ -145,6 +149,7 @@ class Eggs(object):
tuple(links), tuple(links),
index, index,
tuple(allow_hosts), tuple(allow_hosts),
allow_unknown_extras,
) )
if cache_key not in cache_storage: if cache_key not in cache_storage:
if offline: if offline:
...@@ -159,7 +164,8 @@ class Eggs(object): ...@@ -159,7 +164,8 @@ class Eggs(object):
index=index, index=index,
path=[develop_eggs_dir], path=[develop_eggs_dir],
newest=newest, newest=newest,
allow_hosts=allow_hosts) allow_hosts=allow_hosts,
allow_unknown_extras=allow_unknown_extras)
ws = self._sort_working_set(ws) ws = self._sort_working_set(ws)
cache_storage[cache_key] = ws cache_storage[cache_key] = ws
......
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