1
1
#! /usr/bin/env python
3
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
# Copyright (C) 2005, 2006, 2007, 2008, 2009 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
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
19
"""Bazaar -- a free distributed version-control tool"""
25
# update this on each release
26
_script_version = (1, 17, 0)
25
28
if __doc__ is None:
26
29
print "bzr does not support python -OO."
43
46
os.execvp(python, [python] + sys.argv)
46
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
47
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
49
sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
50
sys.stderr.write(" (need %d.%d or later)\n" % NEED_VERS)
49
52
if hasattr(os, "unsetenv"):
50
53
os.unsetenv(REINVOKE)
57
60
profile_imports.install()
63
if sys.platform == 'darwin':
64
# jameinel says this hack is to force python to honor the LANG setting,
65
# even on Darwin. Otherwise it is apparently hardcoded to Mac-Roman,
66
# which is incorrect for the normal Terminal.app which wants UTF-8.
68
# "It might be that I should be setting the "system locale" somewhere else
69
# on the system, rather than setting LANG=en_US.UTF-8 in .bashrc.
70
# Switching to 'posix' and setting LANG worked for me."
72
# So we can remove this if someone works out the right way to tell Mac
73
# Python which encoding to use. -- mbp 20080703
74
sys.platform = 'posix'
78
sys.platform = 'darwin'
83
# The python2.6 release includes some libraries that have deprecation warnings
84
# against the interpreter - see https://bugs.launchpad.net/bzr/+bug/387139
85
warnings.filterwarnings('ignore',
86
r"(struct integer overflow masking is deprecated|"
87
r"'L' format requires 0 <= number <= 4294967295)",
94
locale.setlocale(locale.LC_ALL, '')
95
except locale.Error, e:
96
sys.stderr.write('bzr: warning: %s\n'
97
' bzr could not set the application locale.\n'
98
' Although this should be no problem for bzr itself,\n'
99
' it might cause problems with some plugins.\n'
100
' To investigate the issue, look at the output\n'
101
' of the locale(1p) tool available on POSIX systems.\n'
104
# instruct bzrlib/__init__.py to install lazy_regex
105
sys._bzr_lazy_regex = True
63
108
except ImportError, e:
64
109
sys.stderr.write("bzr: ERROR: "
65
"Couldn't import bzrlib and dependencies.\n"
66
"Please check bzrlib is on your PYTHONPATH.\n"
110
"Couldn't import bzrlib and dependencies.\n"
111
"Please check the directory containing bzrlib is on your PYTHONPATH.\n"
115
if bzrlib.version_info[:3] != _script_version:
116
sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
117
"This may indicate an installation problem.\n"
118
"bzrlib from %s is version %r\n"
119
% (bzrlib.__path__, bzrlib.version_info))
70
121
import bzrlib.inspect_for_copy
71
122
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
73
import bzrlib.lazy_regex
74
bzrlib.lazy_regex.install_lazy_compile()
76
124
import bzrlib.breakin
77
125
bzrlib.breakin.hook_sigquit()
88
136
import bzrlib.commands
89
137
import bzrlib.trace
91
if bzrlib.version_info[:3] != (0, 19, 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))
97
140
if __name__ == '__main__':
98
141
bzrlib.trace.enable_default_logging()
99
exit_val = bzrlib.commands.main(sys.argv)
142
exit_val = bzrlib.commands.main()
102
145
profile_imports.log_stack_info(sys.stderr)
117
160
sys.stderr.flush()
118
161
except IOError, e:
120
if sys.platform != 'win32' or e.errno != errno.EINVAL:
163
if e.errno in [errno.EINVAL, errno.EPIPE]:
122
167
if bzrlib.trace._trace_file:
123
168
# this is also _bzr_log
124
169
bzrlib.trace._trace_file.flush()
125
170
os._exit(exit_val)
127
pass # should this give an error? - it can't be used as a lib
172
raise ImportError("The bzr script cannot be imported.")