2007-03-29 21:01:28 +00:00
|
|
|
#!/usr/bin/env python
|
2006-12-05 19:25:23 +00:00
|
|
|
|
2007-06-06 18:24:00 +00:00
|
|
|
# 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)
|
|
|
|
|
2007-09-15 02:24:28 +00:00
|
|
|
# look for Tahoe.home . Two cases:
|
2007-10-11 10:39:29 +00:00
|
|
|
# ...(not BASE)/tahoe
|
|
|
|
# .../(BASE)/bin/tahoe
|
2007-06-06 18:24:00 +00:00
|
|
|
if len(where) >= 2 and where[-2] == "bin":
|
2007-09-15 02:24:28 +00:00
|
|
|
base = os.sep.join(where[:-2])
|
2007-06-06 18:24:00 +00:00
|
|
|
|
|
|
|
if os.path.exists(os.path.join(base, "Tahoe.home")):
|
2007-09-15 02:24:28 +00:00
|
|
|
# we've found our home. Put the tahoe source at the front of sys.path
|
|
|
|
srcdir = os.path.join(base, "src")
|
|
|
|
sys.path.insert(0, srcdir)
|
|
|
|
# and put any support eggs at the end of sys.path
|
|
|
|
if sys.platform == "win32":
|
|
|
|
supportdir = os.path.join(base, "support", "Lib", "site-packages")
|
|
|
|
else:
|
|
|
|
supportdir = os.path.join(base, "support",
|
|
|
|
"lib",
|
|
|
|
"python%d.%d" % sys.version_info[:2],
|
|
|
|
"site-packages")
|
|
|
|
support_eggs = []
|
|
|
|
if os.path.exists(supportdir):
|
|
|
|
for fn in os.listdir(supportdir):
|
|
|
|
if fn.endswith(".egg"):
|
|
|
|
support_eggs.append(os.path.join(supportdir, fn))
|
|
|
|
|
2008-01-01 08:51:28 +00:00
|
|
|
# We also need to include .egg's in the base dir, because if there is an
|
|
|
|
# .egg there then "make build-deps" will take that as satisfying its
|
|
|
|
# requirements.
|
|
|
|
for fn in os.listdir(base):
|
|
|
|
if fn.endswith(".egg"):
|
|
|
|
support_eggs.append(os.path.abspath(os.path.join(base, fn)))
|
|
|
|
|
2007-09-15 02:24:28 +00:00
|
|
|
sys.path.extend(support_eggs)
|
|
|
|
|
2007-06-06 18:36:48 +00:00
|
|
|
# also update PYTHONPATH so that child processes (like twistd) will
|
|
|
|
# use this too
|
|
|
|
pp = os.environ.get("PYTHONPATH")
|
|
|
|
if pp:
|
2007-09-17 10:43:22 +00:00
|
|
|
pp = os.pathsep.join([srcdir] + pp.split(os.pathsep) + support_eggs)
|
2007-06-06 18:36:48 +00:00
|
|
|
else:
|
2007-09-15 02:24:28 +00:00
|
|
|
pp = os.pathsep.join([srcdir] + support_eggs)
|
2007-06-06 18:36:48 +00:00
|
|
|
os.environ["PYTHONPATH"] = pp
|
2007-06-06 18:24:00 +00:00
|
|
|
|
2006-12-05 19:25:23 +00:00
|
|
|
from allmydata.scripts import runner
|
|
|
|
runner.run()
|