summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-05-23 01:56:27 +0000
committerPJ Eby <distutils-sig@python.org>2005-05-23 01:56:27 +0000
commit2237065782a7ab8265b6127f9352d5f0a9c4fff6 (patch)
tree6a94346f805f6489f4f07c16a06bb1c8acf7f765 /pkg_resources.py
parent489117c324ea90183cbaf5558222b178ae074bed (diff)
downloadpython-setuptools-git-2237065782a7ab8265b6127f9352d5f0a9c4fff6.tar.gz
Add tests for AvailableDistributions().resolve(). This effectively
completes the core dependency resolution engine; all we need now is a way to turn sys.path entries into "distribution sources" that can list Distribution objects for inclusion in an instance of AvailableDistributions, and the 'require("SomePkg>=2.7")' API will be usable. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041009
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 0792adba..1f9be67c 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -250,12 +250,12 @@ class AvailableDistributions(object):
if path is None:
path = sys.path
- requirements = list(requirements)[::1] # set up the stack
+ requirements = list(requirements)[::-1] # set up the stack
processed = {} # set of processed requirements
best = {} # key -> dist
+ to_install = []
while requirements:
-
req = requirements.pop()
if req in processed:
# Ignore cyclic or redundant dependencies
@@ -268,15 +268,16 @@ class AvailableDistributions(object):
dist = best[req.key] = self.best_match(req,path)
if dist is None:
raise DistributionNotFound(req) # XXX put more info here
+ to_install.append(dist)
- elif dist not in requirement:
+ elif dist not in req:
# Oops, the "best" so far conflicts with a dependency
raise VersionConflict(req,dist) # XXX put more info here
requirements.extend(dist.depends(req.options)[::-1])
processed[req] = True
- return best.values() # return list of distros to install
+ return to_install # return list of distros to install
def obtain(self, requirement):
@@ -284,7 +285,6 @@ class AvailableDistributions(object):
return None # override this in subclasses
-
class ResourceManager:
"""Manage resource extraction and packages"""
@@ -418,7 +418,6 @@ def require(*requirements):
* get_distro_source() isn't implemented
* Distribution.install_on() isn't implemented
- * AvailableDistributions.resolve() is untested
* AvailableDistributions.scan() is untested
There may be other things missing as well, but this definitely won't work
@@ -449,6 +448,7 @@ def require(*requirements):
+
class DefaultProvider:
"""Provides access to package resources in the filesystem"""