From: Daira Hopwood Date: Thu, 5 Sep 2013 17:03:06 +0000 (+0100) Subject: Sun May 13 04:47:01 BST 2012 Brian Warner X-Git-Url: https://git.rkrishnan.org/(%5B%5E?a=commitdiff_plain;h=9537da626351a4de9576b01040eead0b0bf981c4;p=tahoe-lafs%2Ftahoe-lafs.git Sun May 13 04:47:01 BST 2012 Brian Warner * rename build_helpers files This is from the darcs patch for #1342, which failed to apply on my darcs tree, so I'm landing it from git. I'm landing the rename-files part separately from the modify-those-files part to avoid VC complications. --- diff --git a/misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py b/misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py new file mode 100644 index 00000000..64d84539 --- /dev/null +++ b/misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python + +import StringIO, os, platform, shutil, subprocess, sys, tarfile, zipfile +import pkg_resources + +def test(): + # We put a "fakedependency-1.0.0.egg" package and a + # "fakedependency-9.9.99.tar.gz" into a directory, but the latter is + # booby-trapped so it will raise an exception when you try to build it. + # + # Then we run + # + # python setup.py --fakedependency -v test -s buildtest.test_build_with_fake_dist + # + # which 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. + # + # 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. + + fake_distdir = 'tahoe-deps' + fake_distname = "fakedependency" + fake_sdistversion = "9.9.99" + fake_bdistversion = "1.0.0" + sdist_setup = "raise Exception('Aha I caught you trying to build me. I am a fakedependency 9.9.99 sdist and you should be satisfied with a bdist.')" + + testsuite = "buildtest.test_build_with_fake_dist" + + 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', '__version__ = "%s"\n' % (fake_bdistversion,)) + 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)) + 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() diff --git a/misc/build_helpers/test-dont-use-too-old-dep.py b/misc/build_helpers/test-dont-use-too-old-dep.py new file mode 100644 index 00000000..f3ecf880 --- /dev/null +++ b/misc/build_helpers/test-dont-use-too-old-dep.py @@ -0,0 +1,30 @@ +#!/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 os, subprocess, sys + +fakepkgdir = 'misc/build_helpers/fakepkgs' +fakepkgname = "pycryptopp" +fakepkgversion = "0.5.13" +testsuite = "allmydata.test.test_backupdb" + +pkgdirname = os.path.join(os.getcwd(), fakepkgdir, '%s-%s.egg' % (fakepkgname, fakepkgversion)) + +try: + os.makedirs(pkgdirname) +except OSError: + # probably already exists + pass + +os.environ['PYTHONPATH']=pkgdirname+os.pathsep+os.environ.get('PYTHONPATH','') +sys.exit(subprocess.call([sys.executable, 'setup.py', 'trial', '-s', testsuite], env=os.environ)) diff --git a/misc/build_helpers/test-with-fake-dists.py b/misc/build_helpers/test-with-fake-dists.py deleted file mode 100644 index 64d84539..00000000 --- a/misc/build_helpers/test-with-fake-dists.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python - -import StringIO, os, platform, shutil, subprocess, sys, tarfile, zipfile -import pkg_resources - -def test(): - # We put a "fakedependency-1.0.0.egg" package and a - # "fakedependency-9.9.99.tar.gz" into a directory, but the latter is - # booby-trapped so it will raise an exception when you try to build it. - # - # Then we run - # - # python setup.py --fakedependency -v test -s buildtest.test_build_with_fake_dist - # - # which 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. - # - # 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. - - fake_distdir = 'tahoe-deps' - fake_distname = "fakedependency" - fake_sdistversion = "9.9.99" - fake_bdistversion = "1.0.0" - sdist_setup = "raise Exception('Aha I caught you trying to build me. I am a fakedependency 9.9.99 sdist and you should be satisfied with a bdist.')" - - testsuite = "buildtest.test_build_with_fake_dist" - - 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', '__version__ = "%s"\n' % (fake_bdistversion,)) - 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)) - 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() diff --git a/misc/build_helpers/test-with-fake-pkg.py b/misc/build_helpers/test-with-fake-pkg.py deleted file mode 100644 index f3ecf880..00000000 --- a/misc/build_helpers/test-with-fake-pkg.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 os, subprocess, sys - -fakepkgdir = 'misc/build_helpers/fakepkgs' -fakepkgname = "pycryptopp" -fakepkgversion = "0.5.13" -testsuite = "allmydata.test.test_backupdb" - -pkgdirname = os.path.join(os.getcwd(), fakepkgdir, '%s-%s.egg' % (fakepkgname, fakepkgversion)) - -try: - os.makedirs(pkgdirname) -except OSError: - # probably already exists - pass - -os.environ['PYTHONPATH']=pkgdirname+os.pathsep+os.environ.get('PYTHONPATH','') -sys.exit(subprocess.call([sys.executable, 'setup.py', 'trial', '-s', testsuite], env=os.environ))