[Python-checkins] python/nondist/sandbox/setuptools/setuptools package_index.py, 1.14, 1.15

pje@users.sourceforge.net pje at users.sourceforge.net
Sun Jul 24 04:41:46 CEST 2005


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

Modified Files:
	package_index.py 
Log Message:
Implement --editable option, which allows you to just download and extract
(or check out from Subversion) one or more source distributions, without
actually building or installing them (or their dependencies).


Index: package_index.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/package_index.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- package_index.py	18 Jul 2005 01:39:45 -0000	1.14
+++ package_index.py	24 Jul 2005 02:41:43 -0000	1.15
@@ -318,7 +318,7 @@
                         (spec,)
                     )
 
-        return self.fetch(spec, tmpdir, force_scan)
+        return self.fetch(spec, tmpdir)
 
 
 
@@ -326,7 +326,7 @@
 
 
 
-    def fetch(self, requirement, tmpdir, force_scan=False):
+    def fetch(self, requirement, tmpdir, force_scan=False, source=False):
         """Obtain a file suitable for fulfilling `requirement`
 
         `requirement` must be a ``pkg_resources.Requirement`` instance.
@@ -336,35 +336,35 @@
         the return value is the same as if you had called the ``download()``
         method with the matching distribution's URL.  If no matching
         distribution is found, returns ``None``.
-        """
 
+        If the `source` flag is set, only source distributions and source
+        checkout links will be considered.
+        """
         # process a Requirement
         self.info("Searching for %s", requirement)
 
+        def find(req):
+            for dist in self.get(req.key, ()):
+                if dist in req and (dist.precedence<=SOURCE_DIST or not source):
+                    self.info("Best match: %s", dist)
+                    return self.download(dist.location, tmpdir)
+            
         if force_scan:
             self.find_packages(requirement)
+            dist = find(requirement)
+        else:
+            dist = find(requirement)
+            if dist is None:
+                self.find_packages(requirement)
+                dist = find(requirement)
 
-        dist = self.best_match(requirement, WorkingSet([]))     # XXX
-
-        if dist is not None:
-            self.info("Best match: %s", dist)
-            return self.download(dist.location, tmpdir)
-
-        self.warn(
-            "No local packages or download links found for %s", requirement
-        )
-        return None
-
-
-
-
-
-
-
-
-
-
-
+        if dist is None:
+            self.warn(
+                "No local packages or download links found for %s%s",
+                (source and "a source distribution of " or ""),
+                requirement,
+            )
+        return dist
 
 
     dl_blocksize = 8192



More information about the Python-checkins mailing list