From: Zooko O'Whielacronx Date: Wed, 17 Nov 2010 08:26:57 +0000 (-0800) Subject: bundled zetuptoolz: prefer locally-available distributions over remotely-downloaded... X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/biz/?a=commitdiff_plain;h=b4c14421f7c2f25aa1839e15d75aa004cf420e67;p=tahoe-lafs%2Ftahoe-lafs.git bundled zetuptoolz: prefer locally-available distributions over remotely-downloaded distributions above all 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. --- diff --git a/setuptools-0.6c16dev2.egg/setuptools/package_index.py b/setuptools-0.6c16dev2.egg/setuptools/package_index.py index 1cfdccc5..3d82d933 100644 --- a/setuptools-0.6c16dev2.egg/setuptools/package_index.py +++ b/setuptools-0.6c16dev2.egg/setuptools/package_index.py @@ -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() diff --git a/src/buildtest/test_build_with_fake_dist.py b/src/buildtest/test_build_with_fake_dist.py index 57a4b533..ec6abe3a 100644 --- a/src/buildtest/test_build_with_fake_dist.py +++ b/src/buildtest/test_build_with_fake_dist.py @@ -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!