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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
from __future__ import absolute_import
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
19
"""Bazaar -- a free distributed version-control tool"""
27
24
# update this on each release
28
_script_version = (2, 8, 0)
32
if sys.version_info < NEED_VERS:
25
_script_version = (1, 6, 0)
28
print "bzr does not support python -OO."
31
version_info = sys.version_info
32
except AttributeError:
33
version_info = 1, 5 # 1.5 or older
35
REINVOKE = "__BZR_REINVOKE"
37
KNOWN_PYTHONS = ('python2.4', 'python2.5')
39
if version_info < NEED_VERS:
40
if not os.environ.has_key(REINVOKE):
41
# mutating os.environ doesn't work in old Pythons
42
os.putenv(REINVOKE, "1")
43
for python in KNOWN_PYTHONS:
45
os.execvp(python, [python] + sys.argv)
33
48
sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
34
49
sys.stderr.write(" (need %d.%d or later)\n" % NEED_VERS)
51
if hasattr(os, "unsetenv"):
39
56
if '--profile-imports' in sys.argv:
57
sys.argv.remove('--profile-imports')
40
58
import profile_imports
41
59
profile_imports.install()
45
if os.name == "posix":
48
locale.setlocale(locale.LC_ALL, '')
49
except locale.Error, e:
50
sys.stderr.write('bzr: warning: %s\n'
51
' bzr could not set the application locale.\n'
52
' Although this should be no problem for bzr itself, it might\n'
53
' cause problems with some plugins. To investigate the issue,\n'
54
' look at the output of the locale(1p) tool.\n' % e)
55
# Use better default than ascii with posix filesystems that deal in bytes
56
# natively even when the C locale or no locale at all is given. Note that
57
# we need an immortal string for the hack, hence the lack of a hyphen.
58
sys._bzr_default_fs_enc = "utf8"
61
# The python2.6 release includes some libraries that have deprecation warnings
62
# against the interpreter - see https://bugs.launchpad.net/bzr/+bug/387139
63
warnings.filterwarnings('ignore',
64
r"(struct integer overflow masking is deprecated|"
65
r"'L' format requires 0 <= number <= 4294967295)",
71
# instruct bzrlib/__init__.py to install lazy_regex
72
sys._bzr_lazy_regex = True
75
65
except ImportError, e:
76
66
sys.stderr.write("bzr: ERROR: "
77
"Couldn't import bzrlib and dependencies.\n"
78
"Please check the directory containing bzrlib is on your PYTHONPATH.\n"
67
"Couldn't import bzrlib and dependencies.\n"
68
"Please check bzrlib is on your PYTHONPATH.\n"
82
72
if bzrlib.version_info[:3] != _script_version:
84
"bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
85
"This may indicate an installation problem.\n"
86
"bzrlib is version %s from %s\n"
87
"bzr is version %s from %s\n" % (
88
bzrlib._format_version_tuple(bzrlib.version_info),
90
bzrlib._format_version_tuple(_script_version),
73
sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
74
"This may indicate an installation problem.\n"
75
"bzrlib from %s is version %r\n"
76
% (bzrlib.__path__, bzrlib.version_info))
94
78
import bzrlib.inspect_for_copy
95
79
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
81
import bzrlib.lazy_regex
82
bzrlib.lazy_regex.install_lazy_compile()
97
84
import bzrlib.breakin
98
bzrlib.breakin.hook_debugger_to_signal()
85
bzrlib.breakin.hook_sigquit()
100
87
import bzrlib.decorators
101
88
if ('--lsprof' in sys.argv
113
100
if __name__ == '__main__':
114
library_state = bzrlib.initialize()
115
library_state.__enter__()
117
exit_val = bzrlib.commands.main()
119
profile_imports.log_stack_info(sys.stderr)
121
library_state.__exit__(None, None, None)
101
bzrlib.trace.enable_default_logging()
102
exit_val = bzrlib.commands.main(sys.argv)
105
profile_imports.log_stack_info(sys.stderr)
107
# run anything registered by atexit, because it won't be run in the normal
123
111
# By this point we really have completed everything we want to do, and
124
112
# there's no point doing any additional cleanup. Abruptly exiting here