2007-03-29 21:01:28 +00:00
|
|
|
#!/usr/bin/env python
|
2006-12-05 19:25:23 +00:00
|
|
|
|
2009-01-09 19:03:00 +00:00
|
|
|
import errno, sys, os, subprocess
|
2008-04-10 21:40:37 +00:00
|
|
|
|
|
|
|
where = os.path.realpath(sys.argv[0])
|
|
|
|
base = os.path.dirname(os.path.dirname(where))
|
|
|
|
|
2008-09-12 01:02:25 +00:00
|
|
|
whoami = '''\
|
|
|
|
I am a "bin/tahoe" executable who is only for the convenience of running
|
|
|
|
Tahoe from its source distribution -- I work only when invoked as the "tahoe"
|
|
|
|
script that lives in the "bin/" subdirectory of a Tahoe source code
|
|
|
|
distribution, and only if you have already run "make".
|
|
|
|
'''
|
|
|
|
|
2008-04-10 21:40:37 +00:00
|
|
|
# look for Tahoe.home .
|
|
|
|
homemarker = os.path.join(base, "Tahoe.home")
|
|
|
|
if not os.path.exists(homemarker):
|
2008-09-12 01:02:25 +00:00
|
|
|
print whoami
|
|
|
|
print '''\
|
|
|
|
I just tried to run and found that I am not living in such a directory, so I
|
|
|
|
am stopping now. To run Tahoe after it has been is installed, please execute
|
|
|
|
my brother, also named "tahoe", who gets installed into the appropriate place
|
|
|
|
for executables when you run "make install" (perhaps as /usr/bin/tahoe).
|
|
|
|
'''
|
2008-04-10 21:40:37 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# we've found our home. Put the tahoe support/lib etc. in our PYTHONPATH.
|
|
|
|
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")
|
|
|
|
|
|
|
|
# update PYTHONPATH so that child processes (like twistd) will use this too
|
|
|
|
pp = os.environ.get("PYTHONPATH")
|
|
|
|
if pp:
|
|
|
|
pp = os.pathsep.join([supportdir] + pp.split(os.pathsep))
|
|
|
|
else:
|
|
|
|
pp = supportdir
|
|
|
|
os.environ["PYTHONPATH"] = pp
|
|
|
|
|
2009-01-09 19:42:22 +00:00
|
|
|
# find the location of the tahoe executable.
|
|
|
|
bin_dir = "bin"
|
|
|
|
if sys.platform == "win32":
|
|
|
|
bin_dir = "Scripts"
|
|
|
|
executable = os.path.join(base, "support", bin_dir, "tahoe")
|
2008-04-10 21:40:37 +00:00
|
|
|
|
|
|
|
try:
|
2009-01-09 19:03:00 +00:00
|
|
|
subprocess.call([executable] + sys.argv[1:], env=os.environ)
|
2008-04-10 21:40:37 +00:00
|
|
|
except (OSError, IOError), le:
|
|
|
|
if le.args[0] == errno.ENOENT:
|
2008-09-12 01:02:25 +00:00
|
|
|
print whoami
|
|
|
|
print '''\
|
|
|
|
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" (perhaps as /usr/bin/tahoe).
|
|
|
|
'''
|
2008-04-10 21:40:37 +00:00
|
|
|
raise
|
|
|
|
except Exception, le:
|
2008-09-12 01:02:25 +00:00
|
|
|
print whoami
|
|
|
|
print '''\
|
|
|
|
I just tried to invoke my brother, named "../support/bin/tahoe" and got an
|
|
|
|
exception.
|
|
|
|
'''
|
2008-04-10 21:40:37 +00:00
|
|
|
raise
|