From: Brian Warner Date: Wed, 6 Jun 2007 18:24:00 +0000 (-0700) Subject: bin/allmydata-tahoe: add a sys.path-modifying preamble to make it easy to run from... X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20//%22?a=commitdiff_plain;h=3c0485204e9455a2e4fb44c8f5ebfd485e70faaf;p=tahoe-lafs%2Ftahoe-lafs.git bin/allmydata-tahoe: add a sys.path-modifying preamble to make it easy to run from source --- diff --git a/Tahoe.home b/Tahoe.home new file mode 100644 index 00000000..f3f4dca7 --- /dev/null +++ b/Tahoe.home @@ -0,0 +1,2 @@ +This file exists so the preamble in bin/allmydata-tahoe can find its source +tree. diff --git a/bin/allmydata-tahoe b/bin/allmydata-tahoe index 8958528e..433095ba 100644 --- a/bin/allmydata-tahoe +++ b/bin/allmydata-tahoe @@ -1,4 +1,25 @@ #!/usr/bin/env python +# This preamble is adapted from Twisted. If we're being run from a source +# tree, add that tree's libdir to our path, so tahoe can be run from source +# without a lot of tedious PYTHONPATH changes. +import sys, os.path +where = os.path.realpath(sys.argv[0]).split(os.sep) + +# look for Tahoe.home . Three cases: +# ...(not BASE)/allmydata-tahoe +# .../(BASE)/bin/allmydata-tahoe +# .../(BASE)/instdir/bin/allmydata-tahoe +if len(where) >= 2 and where[-2] == "bin": + if len(where) >= 3 and where[-3] == "instdir": + base = os.sep.join(where[:-3]) + else: + base = os.sep.join(where[:-2]) + + if os.path.exists(os.path.join(base, "Tahoe.home")): + # we've found our home + libdir = os.path.join(base, "instdir", "lib") + sys.path.insert(0, libdir) + from allmydata.scripts import runner runner.run()