[Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.13, 1.14

pje@users.sourceforge.net pje at users.sourceforge.net
Mon May 23 03:56:29 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17806

Modified Files:
	pkg_resources.py 
Log Message:
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.


Index: pkg_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pkg_resources.py	22 May 2005 20:28:46 -0000	1.13
+++ pkg_resources.py	23 May 2005 01:56:26 -0000	1.14
@@ -250,12 +250,12 @@
         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 @@
                 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 @@
         return None     # override this in subclasses
 
 
-
 class ResourceManager:
     """Manage resource extraction and packages"""
 
@@ -418,7 +418,6 @@
 
         * 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 @@
 
 
 
+
 class DefaultProvider:
     """Provides access to package resources in the filesystem"""
 



More information about the Python-checkins mailing list