]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Make bb-freeze (and probably other static packaging tools) work. This updates various...
authordavid-sarah <david-sarah@jacaranda.org>
Fri, 21 Jan 2011 08:04:29 +0000 (00:04 -0800)
committerdavid-sarah <david-sarah@jacaranda.org>
Fri, 21 Jan 2011 08:04:29 +0000 (00:04 -0800)
src/allmydata/test/test_runner.py
src/allmydata/test/test_system.py
static/tahoe.py [new file with mode: 0644]

index 86d31f50300e069598a920d1d59b21b040ddc21e..a7babdc2a208255cbe56a2965d2e8dcd6ed795b9 100644 (file)
@@ -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):
index ed615981b606188a96f13b677986990b8838fdd8..bf6af0946054573b63b891febd5c5aeb2f5a22ad 100644 (file)
@@ -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 (file)
index 0000000..e22f253
--- /dev/null
@@ -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