diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-03-28 10:55:05 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-03-28 10:55:05 -0400 |
commit | 98277e0581b7123d650169ca82d22e8cb8bd8ad3 (patch) | |
tree | 81a231afcbc2dc8463f1424d043f67f8636cfd68 | |
parent | caf3f78b953542e871e7c0f17ebc9212422dbb56 (diff) | |
parent | b24eb2cc8b7d95d39997e3b79c94544fcf7cefeb (diff) | |
download | python-setuptools-bitbucket-98277e0581b7123d650169ca82d22e8cb8bd8ad3.tar.gz |
Merged in msabramo/setuptools/DistributionNotFound_list_requirers (pull request #126)
DistributionNotFound: Show requirers
-rw-r--r-- | pkg_resources/__init__.py | 33 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 4 |
2 files changed, 27 insertions, 10 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index b12ad0e0..a8a16942 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -369,6 +369,30 @@ class ContextualVersionConflict(VersionConflict): class DistributionNotFound(ResolutionError): """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): """Distribution doesn't have an "extra feature" of the given name""" _provider_factories = {} @@ -799,13 +823,8 @@ class WorkingSet(object): ws = WorkingSet([]) dist = best[req.key] = env.best_match(req, ws, installer) if dist is None: - #msg = ("The '%s' distribution was not found on this " - # "system, and is required by this application.") - #raise DistributionNotFound(msg % req) - - # unfortunately, zc.buildout uses a str(err) - # to get the name of the distribution here.. - raise DistributionNotFound(req) + requirers = required_by.get(req, None) + raise DistributionNotFound(req, requirers) to_activate.append(dist) if dist not in req: # Oops, the "best" so far conflicts with a dependency diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 276b6f99..f2bfa68d 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -709,9 +709,7 @@ class easy_install(Command): [requirement], self.local_index, self.easy_install ) except DistributionNotFound as e: - raise DistutilsError( - "Could not find required distribution %s" % e.args - ) + raise DistutilsError(str(e)) except VersionConflict as e: raise DistutilsError(e.report()) if self.always_copy or self.always_copy_from: |