1 patch for repository zooko@dev.allmydata.org:/home/darcs/tahoe-lafs/trunk: Sun Jan 30 07:38:29 MST 2011 zooko@zooko.com * setup: rename test-with-fake-pkg.py to test-dont-use-too-old-dep.py, fix it to work with "python setup.py test" Copy the technique that David-Sarah used in test-with-fake-dists.py to test a package named "fakedependency" instead of "pycryptopp". This allows us to run "python setup.py test" instead of executing trial directly, which means the test doesn't spuriously fail if some of tahoe-lafs's deps are missing on the buildslave, and the test doesn't skip if pycryptopp is already installed on the buildslave. * rename test-with-fake-dists.py to test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py. New patches: [setup: rename test-with-fake-pkg.py to test-dont-use-too-old-dep.py, fix it to work with "python setup.py test" zooko@zooko.com**20110130143829 Ignore-this: bba1e6aab80cd0b7ed9303d09ff28b2b Copy the technique that David-Sarah used in test-with-fake-dists.py to test a package named "fakedependency" instead of "pycryptopp". This allows us to run "python setup.py test" instead of executing trial directly, which means the test doesn't spuriously fail if some of tahoe-lafs's deps are missing on the buildslave, and the test doesn't skip if pycryptopp is already installed on the buildslave. * rename test-with-fake-dists.py to test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py. ] { move ./misc/build_helpers/test-with-fake-dists.py ./misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py move ./misc/build_helpers/test-with-fake-pkg.py ./misc/build_helpers/test-dont-use-too-old-dep.py hunk ./misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py 15 # # python setup.py --fakedependency -v test -s buildtest.test_build_with_fake_dist # - # which imports fakedependency and passes if fakedependency.__version__ == '1.0.0'. + # which requires "fakedependency >= 1.0.0", imports fakedependency + # and passes if fakedependency.__version__ == '1.0.0'. # # The goal is to turn red if the build system tries to build the # source dist when it could have used the binary dist. hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 3 #!/usr/bin/env python -# We put a fake "pycryptopp-0.5.13" package on the PYTHONPATH so that -# the build system thinks pycryptopp-0.5.13 is already installed. Then -# we execute 'setup.py trial'. If the build system is too naive/greedy -# about finding dependencies, it will latch onto the -# "pycryptopp-0.5.13" and then will be unable to satisfy the -# requirement (from _auto_deps.py) for pycryptopp >= 0.5.20 (or -# pycryptopp >= 0.5.14, depending on machine architecture). This is -# currently happening on trunk, see #1190. So with trunk, running -# test-with-fake-pkg.py shows a failure, but with the ticket1190 -# branch, test-with-fake-pkg.py succeeds. +import StringIO, os, platform, shutil, subprocess, sys, tarfile, zipfile +import pkg_resources hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 6 -import os, subprocess, sys +def test(): + # We put a "fakedependency-0.9.9.egg" package and a + # "fakedependency-1.0.0.tar.gz" into a directory, but the former is + # booby-trapped so it will raise an exception when you try to import it. + # + # Then we run + # + # python setup.py --fakedependency -v test -s buildtest.test_build_with_fake_dist + # + # which requires "fakedependency >= 1.0.0", imports fakedependency + # and passes if fakedependency.__version__ == '1.0.0'. + # + # The goal is to turn red if the build system tries to use the + # source dist when it could have used the binary dist. + # + # Note that for this test to make sense, Tahoe-LAFS needs to be asking + # for a version of fakedependency which can be satisfied by 1.0.0. + # The --fakedependency option to setup.py arranges that. hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 25 -fakepkgdir = 'misc/build_helpers/fakepkgs' -fakepkgname = "pycryptopp" -fakepkgversion = "0.5.13" -testsuite = "allmydata.test.test_backupdb" + fake_distdir = 'tahoe-deps' + fake_distname = "fakedependency" + fake_sdistversion = "1.0.0" + fake_bdistversion = "0.9.9" hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 30 -pkgdirname = os.path.join(os.getcwd(), fakepkgdir, '%s-%s.egg' % (fakepkgname, fakepkgversion)) + bdist_init = "raise Exception('Aha I caught you trying to import me. I am a fakedependency 0.9.9 package and you should not be satisfied with something < 1.0.0.')" + sdist_setup = "import distutils.core\ndistutils.core.setup(name='fakedependency', version='1.0.0', packages=['fakedependency'])" + sdist_init = "__version__ = '%s'" % (fake_sdistversion,) hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 34 -try: - os.makedirs(pkgdirname) -except OSError: - # probably already exists - pass + testsuite = "buildtest.test_build_with_fake_dist" hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 36 -os.environ['PYTHONPATH']=pkgdirname+os.pathsep+os.environ.get('PYTHONPATH','') -sys.exit(subprocess.call([sys.executable, 'setup.py', 'trial', '-s', testsuite], env=os.environ)) + dist_dirname = os.path.join(os.getcwd(), fake_distdir) + + try: + os.makedirs(dist_dirname) + except OSError: + # probably already exists + pass + + bdist_egg_name = os.path.join(dist_dirname, '%s-%s-py%s.%s-%s.egg' % (fake_distname, fake_bdistversion, platform.python_version_tuple()[0], platform.python_version_tuple()[1], pkg_resources.get_supported_platform())) + try: + bdist_egg = zipfile.ZipFile(bdist_egg_name, 'w') + bdist_egg.writestr('fakedependency/__init__.py', bdist_init) + bdist_egg.close() + + sdist_name = os.path.join(dist_dirname, '%s-%s.tar' % (fake_distname, fake_sdistversion)) + sdist = tarfile.open(sdist_name, 'w:gz') + sdist.errorlevel = 2 + tarinfo = tarfile.TarInfo('setup.py') + tarinfo.errorlevel = 2 + tarinfo.size = len(sdist_setup) + sdist.addfile(tarinfo, StringIO.StringIO(sdist_setup)) + tarinfo = tarfile.TarInfo('fakedependency/__init__.py') + tarinfo.errorlevel = 2 + tarinfo.size = len(sdist_init) + sdist.addfile(tarinfo, StringIO.StringIO(sdist_init)) + sdist.close() + + sys.exit(subprocess.call([sys.executable, "setup.py", "--fakedependency", "-v", "test", "-s", testsuite], + env=os.environ)) + finally: + os.remove(bdist_egg_name) + os.remove(sdist_name) + cleanup() + +def cleanup(): + egg_info = os.path.join('src', 'allmydata_tahoe.egg-info') + bin_tahoe = os.path.join('bin', 'tahoe') + bin_tahoe_pyscript = os.path.join('bin', 'tahoe.pyscript') + + if os.path.exists('build'): + shutil.rmtree('build') + if os.path.exists('support'): + shutil.rmtree('support') + if os.path.exists(egg_info): + shutil.rmtree(egg_info) + if os.path.exists(bin_tahoe): + os.remove(bin_tahoe) + if os.path.exists(bin_tahoe_pyscript): + os.remove(bin_tahoe_pyscript) + +if __name__ == '__main__': + test() } Context: [setup: adjust tests to use the new interface of check_requirement which has a 3-tuples instead of a 2-tuple zooko@zooko.com**20110128141546 Ignore-this: d4c6197c78c156e7ae3c3444d81db9ed fixes #1339 ] [src/allmydata/__init__.py: fix #1339, give an indication in the --version[-and-path] output of when the imported setuptools is distribute, and use a separate element in _vers_and_locs_list tuples for information other than the package name and location. This also changes slightly how the sqlite version is reported. david-sarah@jacaranda.org**20110128054150 Ignore-this: 47e8d2afed1f8114681e9094dc93276 ] [TAG allmydata-tahoe-1.8.2b1 warner@lothar.com**20110126061431] Patch bundle hash: 0c710d424ff704d6dfbaf7ec48cdee357e3710d1