]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - bin/allmydata-tahoe
53ad00741f61eec2ab3b513876756a19e90ed076
[tahoe-lafs/tahoe-lafs.git] / bin / allmydata-tahoe
1 #!/usr/bin/env python
2
3 # This preamble is adapted from Twisted. If we're being run from a source
4 # tree, add that tree's libdir to our path, so tahoe can be run from source
5 # without a lot of tedious PYTHONPATH changes.
6 import sys, os.path
7 where = os.path.realpath(sys.argv[0]).split(os.sep)
8
9 # look for Tahoe.home . Three cases:
10 #  ...(not BASE)/allmydata-tahoe
11 #  .../(BASE)/bin/allmydata-tahoe
12 #  .../(BASE)/instdir/bin/allmydata-tahoe
13 if len(where) >= 2 and where[-2] == "bin":
14     if len(where) >= 3 and where[-3] == "instdir":
15         base = os.sep.join(where[:-3])
16     else:
17         base = os.sep.join(where[:-2])
18
19     if os.path.exists(os.path.join(base, "Tahoe.home")):
20         # we've found our home
21         libdir = os.path.join(base, "instdir", "lib")
22         sys.path.insert(0, libdir)
23         # also update PYTHONPATH so that child processes (like twistd) will
24         # use this too
25         pp = os.environ.get("PYTHONPATH")
26         if pp:
27             pp = libdir + ":" + pp
28         else:
29             pp = libdir
30         os.environ["PYTHONPATH"] = pp
31
32 from allmydata.scripts import runner
33 runner.run()