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.
7 where = os.path.realpath(sys.argv[0]).split(os.sep)
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])
17 base = os.sep.join(where[:-2])
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
25 pp = os.environ.get("PYTHONPATH")
27 pp = libdir + ":" + pp
30 os.environ["PYTHONPATH"] = pp
32 from allmydata.scripts import runner