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 . Two cases:
11 # .../(BASE)/bin/tahoe
12 if len(where) >= 2 and where[-2] == "bin":
13 base = os.sep.join(where[:-2])
15 if os.path.exists(os.path.join(base, "Tahoe.home")):
16 # we've found our home. Put the tahoe source at the front of sys.path
17 srcdir = os.path.join(base, "src")
18 sys.path.insert(0, srcdir)
19 # and put any support eggs at the end of sys.path
20 if sys.platform == "win32":
21 supportdir = os.path.join(base, "support", "Lib", "site-packages")
23 supportdir = os.path.join(base, "support",
25 "python%d.%d" % sys.version_info[:2],
28 if os.path.exists(supportdir):
29 for fn in os.listdir(supportdir):
30 if fn.endswith(".egg"):
31 support_eggs.append(os.path.join(supportdir, fn))
33 sys.path.extend(support_eggs)
35 # also update PYTHONPATH so that child processes (like twistd) will
37 pp = os.environ.get("PYTHONPATH")
39 pp = os.pathsep.join([srcdir] + pp.split(os.pathsep) + support_eggs)
41 pp = os.pathsep.join([srcdir] + support_eggs)
42 os.environ["PYTHONPATH"] = pp
44 from allmydata.scripts import runner