1
1
#! /usr/bin/env python
3
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
3
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
45
43
os.execvp(python, [python] + sys.argv)
48
sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
49
sys.stderr.write(" (need %d.%d or later)\n" % NEED_VERS)
46
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
47
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
51
49
if hasattr(os, "unsetenv"):
52
50
os.unsetenv(REINVOKE)
59
57
profile_imports.install()
62
if sys.platform == 'darwin':
63
# jameinel says this hack is to force python to honor the LANG setting,
64
# even on Darwin. Otherwise it is apparently hardcoded to Mac-Roman,
65
# which is incorrect for the normal Terminal.app which wants UTF-8.
67
# "It might be that I should be setting the "system locale" somewhere else
68
# on the system, rather than setting LANG=en_US.UTF-8 in .bashrc.
69
# Switching to 'posix' and setting LANG worked for me."
71
# So we can remove this if someone works out the right way to tell Mac
72
# Python which encoding to use. -- mbp 20080703
73
sys.platform = 'posix'
77
sys.platform = 'darwin'
82
locale.setlocale(locale.LC_ALL, '')
83
except locale.Error, e:
84
sys.stderr.write('bzr: warning: %s\n'
85
' bzr could not set the application locale.\n'
86
' Although this should be no problem for bzr itself,\n'
87
' it might cause problems with some plugins.\n'
88
' To investigate the issue, look at the output\n'
89
' of the locale(1p) tool available on POSIX systems.\n'
94
63
except ImportError, e:
95
64
sys.stderr.write("bzr: ERROR: "
96
"Couldn't import bzrlib and dependencies.\n"
97
"Please check the directory containing bzrlib is on your PYTHONPATH.\n"
65
"Couldn't import bzrlib and dependencies.\n"
66
"Please check bzrlib is on your PYTHONPATH.\n"
101
if bzrlib.version_info[:3] != _script_version:
102
sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
103
"This may indicate an installation problem.\n"
104
"bzrlib from %s is version %r\n"
105
% (bzrlib.__path__, bzrlib.version_info))
107
70
import bzrlib.inspect_for_copy
108
71
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
125
88
import bzrlib.commands
126
89
import bzrlib.trace
91
if bzrlib.version_info[:3] != (0, 17, 0):
92
sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
93
"This may indicate an installation problem.\n"
94
"bzrlib from %s is version %r\n"
95
% (bzrlib.__path__, bzrlib.version_info))
129
97
if __name__ == '__main__':
130
98
bzrlib.trace.enable_default_logging()
134
102
profile_imports.log_stack_info(sys.stderr)
136
# run anything registered by atexit, because it won't be run in the normal
140
104
# By this point we really have completed everything we want to do, and
141
105
# there's no point doing any additional cleanup. Abruptly exiting here
142
106
# stops any background threads getting into trouble as code is unloaded,
149
113
sys.stderr.flush()
150
114
except IOError, e:
152
if e.errno in [errno.EINVAL, errno.EPIPE]:
116
if sys.platform != 'win32' or e.errno != errno.EINVAL:
156
118
if bzrlib.trace._trace_file:
157
119
# this is also _bzr_log
158
120
bzrlib.trace._trace_file.flush()
159
121
os._exit(exit_val)
161
raise ImportError("The bzr script cannot be imported.")
123
pass # should this give an error? - it can't be used as a lib