Commit 6bb8f3a7 authored by Jason R. Coombs's avatar Jason R. Coombs

Merged in msabramo/setuptools/DistributionNotFound_list_requirers (pull request #126)

DistributionNotFound: Show requirers
parents f0b26583 e1f0b401
...@@ -369,6 +369,30 @@ class ContextualVersionConflict(VersionConflict): ...@@ -369,6 +369,30 @@ class ContextualVersionConflict(VersionConflict):
class DistributionNotFound(ResolutionError): class DistributionNotFound(ResolutionError):
"""A requested distribution was not found""" """A requested distribution was not found"""
_template = ("The '{self.req}' distribution was not found "
"and is required by {self.requirers_str}")
@property
def req(self):
return self.args[0]
@property
def requirers(self):
return self.args[1]
@property
def requirers_str(self):
if not self.requirers:
return 'the application'
return ', '.join(self.requirers)
def report(self):
return self._template.format(**locals())
def __str__(self):
return self.report()
class UnknownExtra(ResolutionError): class UnknownExtra(ResolutionError):
"""Distribution doesn't have an "extra feature" of the given name""" """Distribution doesn't have an "extra feature" of the given name"""
_provider_factories = {} _provider_factories = {}
...@@ -799,13 +823,8 @@ class WorkingSet(object): ...@@ -799,13 +823,8 @@ class WorkingSet(object):
ws = WorkingSet([]) ws = WorkingSet([])
dist = best[req.key] = env.best_match(req, ws, installer) dist = best[req.key] = env.best_match(req, ws, installer)
if dist is None: if dist is None:
#msg = ("The '%s' distribution was not found on this " requirers = required_by.get(req, None)
# "system, and is required by this application.") raise DistributionNotFound(req, requirers)
#raise DistributionNotFound(msg % req)
# unfortunately, zc.buildout uses a str(err)
# to get the name of the distribution here..
raise DistributionNotFound(req)
to_activate.append(dist) to_activate.append(dist)
if dist not in req: if dist not in req:
# Oops, the "best" so far conflicts with a dependency # Oops, the "best" so far conflicts with a dependency
......
...@@ -709,9 +709,7 @@ class easy_install(Command): ...@@ -709,9 +709,7 @@ class easy_install(Command):
[requirement], self.local_index, self.easy_install [requirement], self.local_index, self.easy_install
) )
except DistributionNotFound as e: except DistributionNotFound as e:
raise DistutilsError( raise DistutilsError(str(e))
"Could not find required distribution %s" % e.args
)
except VersionConflict as e: except VersionConflict as e:
raise DistutilsError(e.report()) raise DistutilsError(e.report())
if self.always_copy or self.always_copy_from: if self.always_copy or self.always_copy_from:
......
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