]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
bundled zetuptoolz: prefer locally-available distributions over remotely-downloaded...
authorZooko O'Whielacronx <zooko@zooko.com>
Wed, 17 Nov 2010 08:26:57 +0000 (00:26 -0800)
committerZooko O'Whielacronx <zooko@zooko.com>
Wed, 17 Nov 2010 08:26:57 +0000 (00:26 -0800)
This fixes #1233. Actually the previous patches—[20101103034740-93fa1-9df33552497282eb72a84e5b434d035974bf2dbb] and [20101117080828-92b7f-dc0239f30b26e7e5d40b228114fb399c1e190ec5]—fixed it, but with them zetuptoolz would download a higher-numbered distribution from the net instead of using the locally-available (fake) pycryptopp-0.5.24, thus preventing the tests from passing. This patch changes that behavior (which is an improvement in its own right) and also fixes a bug in the tests.

setuptools-0.6c16dev2.egg/setuptools/package_index.py
src/buildtest/test_build_with_fake_dist.py

index 1cfdccc52175eb74474606b5d8be39e105cc747a..3d82d933179c73de16455fbb6cb8f189ff0bd6ab 100644 (file)
@@ -19,6 +19,21 @@ PYPI_MD5 = re.compile(
 URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match
 EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split()
 
+def is_local(url_or_fname):
+    """ Return True if url_or_fname is a "file:" url or if it is a schemaless thing (which is presumably a filename). """
+    mo = URL_SCHEME(url_or_fname)
+    return not (mo and mo.group(1).lower()!='file')
+
+def url_or_fname_to_fname(url_or_fname):
+    """ Assert that is_local(url_or_fname) then if it is a "file:" url, parse it and run url2pathname on it, else just return it. """
+    assert is_local(url_or_fname)
+
+    mo = URL_SCHEME(url_or_fname)
+    if mo:
+        return urllib2.url2pathname(urlparse.urlparse(url)[2])
+    else:
+        return url_or_fname
+
 __all__ = [
     'PackageIndex', 'distros_for_url', 'parse_bdist_wininst',
     'interpret_distro_name',
@@ -436,18 +451,22 @@ class PackageIndex(Environment):
         def find(env, req):
             # Find a matching distribution; may be called more than once
 
-            # first try to find a platform-dependent dist
-            for allow_platform_independent in (False, True):
-                for dist in env[req.key]:
-                    if dist.precedence==DEVELOP_DIST and not develop_ok:
-                        if dist not in skipped:
-                            self.warn("Skipping development or system egg: %s",dist)
-                            skipped[dist] = 1
-                        continue
-
-                    if (dist in req and (allow_platform_independent or dist.platform is not None) and
-                        (dist.precedence<=SOURCE_DIST or not source)):
-                        return dist
+            # first try to find a local dist
+            for allow_remote in (False, True):
+                # then try to find a platform-dependent dist
+                for allow_platform_independent in (False, True):
+                    for dist in env[req.key]:
+                        if dist.precedence==DEVELOP_DIST and not develop_ok:
+                            if dist not in skipped:
+                                self.warn("Skipping development or system egg: %s",dist)
+                                skipped[dist] = 1
+                            continue
+
+                        if ((is_local(dist.location) or allow_remote) and
+                            (dist in req) and
+                            ((allow_platform_independent or dist.platform is not None) and
+                             (dist.precedence<=SOURCE_DIST or not source))):
+                            return dist
 
         if force_scan:
             self.prescan()
index 57a4b533f90f326c47f598589596e0579d915ac1..ec6abe3ab7f5ba82b112a6e6d6d2f9c82228ebf8 100644 (file)
@@ -7,4 +7,4 @@ class T(unittest.TestCase):
         import pycryptopp
         if pycryptopp.__version__ != '0.5.24':
             raise unittest.SkipTest("We can't tell if this worked because this system has a different version of pycryptopp already installed. See comment in misc/build_helpers/test-with-fake-dists.py for details.")
-        self.succeed()
+        # If you tried to build 9.9.99 then you would have gotten an exception and stopped before you even ran this test, so I guess you succeeded!