1
1
#! /usr/bin/env python
3
# This is an installation script for bzr. Run it with
4
# './setup.py install', or
5
# './setup.py --help' for more options
3
"""Installation script for bzr.
5
'./setup.py install', or
6
'./setup.py --help' for more options
12
# META INFORMATION FOR SETUP
14
META_INFO = {'name': 'bzr',
15
'version': bzrlib.__version__,
16
'author': 'Canonical Ltd',
17
'author_email': 'bazaar-ng@lists.ubuntu.com',
18
'url': 'http://www.bazaar-vcs.org/',
19
'description': 'Friendly distributed version control system',
20
'license': 'GNU GPL v2',
23
BZRLIB = {'packages': ['bzrlib',
25
'bzrlib.benchmarks.tree_creator',
27
'bzrlib.bundle.serializer',
32
'bzrlib.plugins.launchpad',
34
'bzrlib.store.revision',
35
'bzrlib.store.versioned',
37
'bzrlib.tests.blackbox',
38
'bzrlib.tests.branch_implementations',
39
'bzrlib.tests.bzrdir_implementations',
40
'bzrlib.tests.interrepository_implementations',
41
'bzrlib.tests.intertree_implementations',
42
'bzrlib.tests.interversionedfile_implementations',
43
'bzrlib.tests.repository_implementations',
44
'bzrlib.tests.revisionstore_implementations',
45
'bzrlib.tests.tree_implementations',
46
'bzrlib.tests.workingtree_implementations',
48
'bzrlib.transport.http',
51
'bzrlib.util.configobj',
52
'bzrlib.util.effbot.org',
53
'bzrlib.util.elementtree',
57
PKG_DATA = {# install files from selftest suite
58
'package_data': {'bzrlib': ['doc/api/*.txt',
59
'tests/test_patches_data/*',
63
######################################################################
64
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
65
# including bzrlib.help
71
version_info = sys.version_info
72
except AttributeError:
73
version_info = 1, 5 # 1.5 or older
75
REINVOKE = "__BZR_REINVOKE"
77
KNOWN_PYTHONS = ('python2.4',)
79
if version_info < NEED_VERS:
80
if not os.environ.has_key(REINVOKE):
81
# mutating os.environ doesn't work in old Pythons
82
os.putenv(REINVOKE, "1")
83
for python in KNOWN_PYTHONS:
85
os.execvp(python, [python] + sys.argv)
88
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
89
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
91
if hasattr(os, "unsetenv"):
7
95
from distutils.core import setup
12
author_email='mbp@sourcefrog.net',
13
url='http://www.bazaar-ng.org/',
14
description='Friendly distributed version control system',
96
from distutils.command.install_scripts import install_scripts
97
from distutils.command.build import build
99
###############################
100
# Overridden distutils actions
101
###############################
103
class my_install_scripts(install_scripts):
104
""" Customized install_scripts distutils action.
105
Create bzr.bat for win32.
111
install_scripts.run(self) # standard action
113
if sys.platform == "win32":
115
scripts_dir = self.install_dir
116
script_path = self._quoted_path(os.path.join(scripts_dir,
118
python_exe = self._quoted_path(sys.executable)
119
args = self._win_batch_args()
120
batch_str = "@%s %s %s" % (python_exe, script_path, args)
121
batch_path = script_path + ".bat"
122
f = file(batch_path, "w")
125
print "Created:", batch_path
127
print "ERROR: Unable to create %s: %s" % (batch_path, e)
129
def _quoted_path(self, path):
131
return '"' + path + '"'
135
def _win_batch_args(self):
139
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
140
#/class my_install_scripts
143
class bzr_build(build):
144
"""Customized build distutils action.
151
generate_docs.main(argv=["bzr", "man"])
154
########################
156
########################
158
if 'bdist_wininst' in sys.argv:
161
docs = glob.glob('doc/*.htm') + ['doc/default.css']
162
# python's distutils-based win32 installer
163
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
165
'data_files': [('Doc/Bazaar', docs)],
168
ARGS.update(META_INFO)
170
ARGS.update(PKG_DATA)
174
elif 'py2exe' in sys.argv:
178
# pick real bzr version
182
for i in bzrlib.version_info[:4]:
187
version_number.append(str(i))
188
version_str = '.'.join(version_number)
190
target = py2exe.build_exe.Target(script = "bzr",
192
icon_resources = [(0,'bzr.ico')],
193
name = META_INFO['name'],
194
version = version_str,
195
description = META_INFO['description'],
196
author = META_INFO['author'],
197
copyright = "(c) Canonical Ltd, 2005-2006",
198
company_name = "Canonical Ltd.",
199
comments = META_INFO['description'],
201
options_list = {"py2exe": {"packages": BZRLIB['packages'] +
203
"excludes": ["Tkinter", "medusa"],
204
"dist_dir": "win32_bzr.exe",
207
setup(options=options_list,
209
'tools/win32/bzr_postinstall.py',
211
zipfile='lib/library.zip')
215
ARGS = {'scripts': ['bzr'],
216
'data_files': [('man/man1', ['bzr.1'])],
217
'cmdclass': {'build': bzr_build,
218
'install_scripts': my_install_scripts,
222
ARGS.update(META_INFO)
224
ARGS.update(PKG_DATA)