aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg_resources.py14
-rwxr-xr-xpkg_resources.txt3
-rw-r--r--setuptools/tests/test_resources.py12
3 files changed, 16 insertions, 13 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 15dca3c1..f946fc4e 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -463,7 +463,7 @@ class WorkingSet(object):
requirements = list(requirements)[::-1] # set up the stack
processed = {} # set of processed requirements
- best = dict([(d.key,d) for d in self]) # key -> dist
+ best = {} # key -> dist
to_activate = []
while requirements:
@@ -471,20 +471,20 @@ class WorkingSet(object):
if req in processed:
# Ignore cyclic or redundant dependencies
continue
-
dist = best.get(req.key)
if dist is None:
# Find the best distribution and add it to the map
- if env is None:
- env = Environment(self.entries)
- dist = best[req.key] = env.best_match(req, self, installer)
+ dist = self.by_key.get(req.key)
if dist is None:
- raise DistributionNotFound(req) # XXX put more info here
+ if env is None:
+ env = Environment(self.entries)
+ dist = best[req.key] = env.best_match(req, self, installer)
+ if dist is None:
+ raise DistributionNotFound(req) # XXX put more info here
to_activate.append(dist)
elif dist not in req:
# Oops, the "best" so far conflicts with a dependency
raise VersionConflict(dist,req) # XXX put more info here
-
requirements.extend(dist.requires(req.extras)[::-1])
processed[req] = True
diff --git a/pkg_resources.txt b/pkg_resources.txt
index e9e5286d..62b57dc5 100755
--- a/pkg_resources.txt
+++ b/pkg_resources.txt
@@ -1488,6 +1488,9 @@ File/Path Utilities
Release Notes/Change History
----------------------------
+0.6a4
+ * Fix a bug in ``WorkingSet.resolve()`` that was introduced in 0.6a3.
+
0.6a3
* Added ``safe_extra()`` parsing utility routine, and use it for Requirement,
EntryPoint, and Distribution objects' extras handling.
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 87648f1c..5b9751f9 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -123,7 +123,6 @@ class DistroTests(TestCase):
def testResolve(self):
ad = Environment([]); ws = WorkingSet([])
-
# Resolving no requirements -> nothing to install
self.assertEqual( list(ws.resolve([],ad)), [] )
@@ -131,7 +130,6 @@ class DistroTests(TestCase):
self.assertRaises(
DistributionNotFound, ws.resolve, parse_requirements("Foo"), ad
)
-
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.egg",
metadata=Metadata(('depends.txt', "[bar]\nBaz>=2.0"))
@@ -139,10 +137,12 @@ class DistroTests(TestCase):
ad.add(Foo)
# Request thing(s) that are available -> list to activate
- self.assertEqual(
- list(ws.resolve(parse_requirements("Foo"), ad)), [Foo]
- )
-
+ for i in range(3):
+ targets = list(ws.resolve(parse_requirements("Foo"), ad))
+ self.assertEqual(targets, [Foo])
+ map(ws.add,targets)
+ ws = WorkingSet([]) # reset
+
# Request an extra that causes an unresolved dependency for "Baz"
self.assertRaises(
DistributionNotFound, ws.resolve,parse_requirements("Foo[bar]"), ad