aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2014-10-10 11:48:58 -0700
committerMarc Abramowitz <marc@marc-abramowitz.com>2014-10-10 11:48:58 -0700
commit35f70a6a7962643f32b87a6d9a125292060a60b1 (patch)
treed8e0fb55cfcc18900467d0e829fb602a60f2311e /pkg_resources.py
parent42328153d2e438b94544568b9373e674cf4ac3b8 (diff)
downloadexternal_python_setuptools-35f70a6a7962643f32b87a6d9a125292060a60b1.tar.gz
external_python_setuptools-35f70a6a7962643f32b87a6d9a125292060a60b1.tar.bz2
external_python_setuptools-35f70a6a7962643f32b87a6d9a125292060a60b1.zip
Make VersionConflict report who is requiring package
fixes issue 268 --HG-- branch : BB-268_make_VersionConflict_report_who_required_package_3
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 517298c9..1ca8dd8e 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -589,6 +589,9 @@ class WorkingSet(object):
# key -> dist
best = {}
to_activate = []
+ # key with req -> set of things that required it
+ # useful for reporting info about conflicts
+ required_by = collections.defaultdict(set)
while requirements:
# process dependencies breadth-first
@@ -624,8 +627,13 @@ class WorkingSet(object):
if dist not in req:
# Oops, the "best" so far conflicts with a dependency
# XXX put more info here
- raise VersionConflict(dist, req)
- requirements.extend(dist.requires(req.extras)[::-1])
+ raise VersionConflict(
+ "%s is installed but %s is required by %s"
+ % (dist, req, list(required_by.get(req))))
+ new_requirements = dist.requires(req.extras)[::-1]
+ requirements.extend(new_requirements)
+ for new_requirement in new_requirements:
+ required_by[new_requirement].add(req.project_name)
processed[req] = True
# return list of distros to activate