]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - bin/tahoe
setup: execute ../support/bin/tahoe from ./bin/tahoe
[tahoe-lafs/tahoe-lafs.git] / bin / tahoe
1 #!/usr/bin/env python
2
3 import errno, sys, os
4
5 where = os.path.realpath(sys.argv[0])
6 base = os.path.dirname(os.path.dirname(where))
7
8 # look for Tahoe.home .
9 homemarker = os.path.join(base, "Tahoe.home")
10 if not os.path.exists(homemarker):
11     print "I am a \"bin/tahoe\" executable who is only for the convenience of running Tahoe from its source distribution -- I work only when run from the \"bin/\" subdirectory of a Tahoe source code distribution, and only if you have already run \"make\".  I just tried to run and found that I am not in the bin/ subdirectory of a Tahoe source distribution, so I am stopping now.  To run Tahoe when it is installed, please execute my brother, also named \"tahoe\", who gets installed into the appropriate place for executables when you run \"make install\"."
12     sys.exit(1)
13
14 # we've found our home. Put the tahoe support/lib etc. in our PYTHONPATH.
15 if sys.platform == "win32":
16     supportdir = os.path.join(base, "support", "Lib", "site-packages")
17 else:
18     supportdir = os.path.join(base, "support",
19                               "lib",
20                               "python%d.%d" % sys.version_info[:2],
21                               "site-packages")
22
23 # update PYTHONPATH so that child processes (like twistd) will use this too
24 pp = os.environ.get("PYTHONPATH")
25 if pp:
26     pp = os.pathsep.join([supportdir] + pp.split(os.pathsep))
27 else:
28     pp = supportdir
29 os.environ["PYTHONPATH"] = pp
30
31 executable = os.path.join(base, "support", "bin", "tahoe")
32
33 try:
34     os.execve(executable, [executable] + sys.argv[1:], os.environ)
35 except (OSError, IOError), le:
36     if le.args[0] == errno.ENOENT:
37         print "I am a \"bin/tahoe\" executable who is only for the convenience of running Tahoe from its source distribution -- I work only when run from the \"bin/\" subdirectory of a Tahoe source code distribution, and only if you have already run \"make\".  I just tried to run and could not find my brother, named \"../support/bin/tahoe\".  To run Tahoe when it is installed, please execute my brother, also named \"tahoe\", who gets installed into the appropriate place for executables when you run \"make install\"."
38         raise
39 except Exception, le:
40     print "I am a \"bin/tahoe\" executable who is only for the convenience of running Tahoe from its source distribution -- I work only when run from the \"bin/\" subdirectory of a Tahoe source code distribution, and only if you have already run \"make\".  I just tried to invoke my brother, named \"../support/bin/tahoe\" and got an exception."
41     raise
42
43