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',
26
'bzrlib.bundle.serializer',
31
'bzrlib.plugins.launchpad',
33
'bzrlib.store.revision',
34
'bzrlib.store.versioned',
36
'bzrlib.tests.blackbox',
37
'bzrlib.tests.branch_implementations',
38
'bzrlib.tests.bzrdir_implementations',
39
'bzrlib.tests.interrepository_implementations',
40
'bzrlib.tests.intertree_implementations',
41
'bzrlib.tests.interversionedfile_implementations',
42
'bzrlib.tests.repository_implementations',
43
'bzrlib.tests.revisionstore_implementations',
44
'bzrlib.tests.tree_implementations',
45
'bzrlib.tests.workingtree_implementations',
47
'bzrlib.transport.http',
50
'bzrlib.util.configobj',
51
'bzrlib.util.effbot.org',
52
'bzrlib.util.elementtree',
56
PKG_DATA = {# install files from selftest suite
57
'package_data': {'bzrlib': ['doc/api/*.txt',
58
'tests/test_patches_data/*',
62
######################################################################
63
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
64
# including bzrlib.help
70
version_info = sys.version_info
71
except AttributeError:
72
version_info = 1, 5 # 1.5 or older
74
REINVOKE = "__BZR_REINVOKE"
76
KNOWN_PYTHONS = ('python2.4',)
78
if version_info < NEED_VERS:
79
if not os.environ.has_key(REINVOKE):
80
# mutating os.environ doesn't work in old Pythons
81
os.putenv(REINVOKE, "1")
82
for python in KNOWN_PYTHONS:
84
os.execvp(python, [python] + sys.argv)
87
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
88
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
90
if hasattr(os, "unsetenv"):
7
94
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',
20
'bzrlib.util.elementtree',
21
'bzrlib.util.effbot.org',
95
from distutils.command.install_scripts import install_scripts
96
from distutils.command.build import build
98
###############################
99
# Overridden distutils actions
100
###############################
102
class my_install_scripts(install_scripts):
103
""" Customized install_scripts distutils action.
104
Create bzr.bat for win32.
110
install_scripts.run(self) # standard action
112
if sys.platform == "win32":
114
scripts_dir = self.install_dir
115
script_path = self._quoted_path(os.path.join(scripts_dir,
117
python_exe = self._quoted_path(sys.executable)
118
args = self._win_batch_args()
119
batch_str = "@%s %s %s" % (python_exe, script_path, args)
120
batch_path = script_path + ".bat"
121
f = file(batch_path, "w")
124
print "Created:", batch_path
126
print "ERROR: Unable to create %s: %s" % (batch_path, e)
128
def _quoted_path(self, path):
130
return '"' + path + '"'
134
def _win_batch_args(self):
138
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
139
#/class my_install_scripts
142
class bzr_build(build):
143
"""Customized build distutils action.
150
generate_docs.main(argv=["bzr", "man"])
153
########################
155
########################
157
if 'bdist_wininst' in sys.argv:
160
docs = glob.glob('doc/*.htm') + ['doc/default.css']
161
# python's distutils-based win32 installer
162
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
164
'data_files': [('Doc/Bazaar', docs)],
167
ARGS.update(META_INFO)
169
ARGS.update(PKG_DATA)
173
elif 'py2exe' in sys.argv:
177
# pick real bzr version
181
for i in bzrlib.version_info[:4]:
186
version_number.append(str(i))
187
version_str = '.'.join(version_number)
189
target = py2exe.build_exe.Target(script = "bzr",
191
icon_resources = [(0,'bzr.ico')],
192
name = META_INFO['name'],
193
version = version_str,
194
description = META_INFO['description'],
195
author = META_INFO['author'],
196
copyright = "(c) Canonical Ltd, 2005-2006",
197
company_name = "Canonical Ltd.",
198
comments = META_INFO['description'],
200
options_list = {"py2exe": {"packages": BZRLIB['packages'] +
202
"excludes": ["Tkinter", "medusa"],
203
"dist_dir": "win32_bzr.exe",
206
setup(options=options_list,
208
'tools/win32/bzr_postinstall.py',
210
zipfile='lib/library.zip')
214
ARGS = {'scripts': ['bzr'],
215
'data_files': [('man/man1', ['bzr.1'])],
216
'cmdclass': {'build': bzr_build,
217
'install_scripts': my_install_scripts,
221
ARGS.update(META_INFO)
223
ARGS.update(PKG_DATA)