From: david-sarah Date: Fri, 21 Jan 2011 08:04:29 +0000 (-0800) Subject: Make bb-freeze (and probably other static packaging tools) work. This updates various... X-Git-Tag: allmydata-tahoe-1.8.2b1~18 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service?a=commitdiff_plain;h=8587c63bdc291faf08d54128970905db37188fb2;p=tahoe-lafs%2Ftahoe-lafs.git Make bb-freeze (and probably other static packaging tools) work. This updates various places where we assumed that the tahoe process was executed via the Python interpreter. It also allows tests to recursively invoke the same tahoe.exe, rather than bin/tahoe. refs #585 --- diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 86d31f50..a7babdc2 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -31,13 +31,18 @@ def get_root_from_file(src): srcfile = allmydata.__file__ rootdir = get_root_from_file(srcfile) -bintahoe = os.path.join(rootdir, 'bin', 'tahoe') -if sys.platform == "win32": - bintahoe += ".pyscript" - if not os.path.exists(bintahoe): - alt_bintahoe = os.path.join(rootdir, 'Scripts', 'tahoe.pyscript') - if os.path.exists(alt_bintahoe): - bintahoe = alt_bintahoe +if hasattr(sys, 'frozen'): + bintahoe = os.path.join(rootdir, 'tahoe') + if sys.platform == "win32" and os.path.exists(bintahoe + '.exe'): + bintahoe += '.exe' +else: + bintahoe = os.path.join(rootdir, 'bin', 'tahoe') + if sys.platform == "win32": + bintahoe += '.pyscript' + if not os.path.exists(bintahoe): + alt_bintahoe = os.path.join(rootdir, 'Scripts', 'tahoe.pyscript') + if os.path.exists(alt_bintahoe): + bintahoe = alt_bintahoe class RunBinTahoeMixin: @@ -53,7 +58,14 @@ class RunBinTahoeMixin: def run_bintahoe(self, args, stdin=None, python_options=[], env=None): self.skip_if_cannot_run_bintahoe() - command = [sys.executable] + python_options + [bintahoe] + args + + if hasattr(sys, 'frozen'): + if python_options: + raise unittest.SkipTest("This test doesn't apply to frozen builds.") + command = [bintahoe] + args + else: + command = [sys.executable] + python_options + [bintahoe] + args + if stdin is None: stdin_stream = None else: @@ -69,6 +81,9 @@ class RunBinTahoeMixin: class BinTahoe(common_util.SignalMixin, unittest.TestCase, RunBinTahoeMixin): def _check_right_code(self, file_to_check): root_to_check = get_root_from_file(file_to_check) + if os.path.basename(root_to_check) == 'dist': + root_to_check = os.path.dirname(root_to_check) + cwd = os.path.normcase(os.path.realpath(".")) root_from_cwd = os.path.dirname(cwd) if os.path.basename(root_from_cwd) == 'src': @@ -172,8 +187,6 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, RunBinTahoeMixin): return d def test_run_with_python_options(self): - self.skip_if_cannot_run_bintahoe() - # -t is a harmless option that warns about tabs. d = self.run_bintahoe(["--version"], python_options=["-t"]) def _cb(res): diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index ed615981..bf6af094 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -30,7 +30,7 @@ from twisted.web.error import Error from allmydata.test.common import SystemTestMixin -# TODO: move these to common or common_util +# TODO: move this to common or common_util from allmydata.test.test_runner import RunBinTahoeMixin LARGE_DATA = """ diff --git a/static/tahoe.py b/static/tahoe.py new file mode 100644 index 00000000..e22f2534 --- /dev/null +++ b/static/tahoe.py @@ -0,0 +1,27 @@ + +# This checks that we can import the right versions of all dependencies. +# Import this first to suppress deprecation warnings. +import allmydata + +# nevow requires all these for its voodoo module import time adaptor registrations +from nevow import accessors, appserver, static, rend, url, util, query, i18n, flat +from nevow import guard, stan, testutil, context +from nevow.flat import flatmdom, flatstan, twist +from formless import webform, processors, annotate, iformless +from decimal import Decimal +from xml.dom import minidom + +import allmydata.web + +import mock + +# junk to appease pyflakes's outrage +[ + accessors, appserver, static, rend, url, util, query, i18n, flat, guard, stan, testutil, + context, flatmdom, flatstan, twist, webform, processors, annotate, iformless, Decimal, + minidom, allmydata, mock, +] + +from allmydata.scripts import runner + +runner.run() \ No newline at end of file