1
1
#! /usr/bin/env python
3
"""Installation script for bzr.
5
'./setup.py install', or
6
'./setup.py --help' for more options
10
# META INFORMATION FOR SETUP
12
META_INFO = {'name': 'bzr',
13
'version': '<unknown>',
14
'author': 'Canonical Ltd',
15
'author_email': 'bazaar-ng@lists.ubuntu.com',
16
'url': 'http://www.bazaar-vcs.org/',
17
'description': 'Friendly distributed version control system',
18
'license': 'GNU GPL v2',
21
BZRLIB = {'packages': ['bzrlib',
24
'bzrlib.bundle.serializer',
29
'bzrlib.plugins.launchpad',
31
'bzrlib.store.revision',
32
'bzrlib.store.versioned',
34
'bzrlib.tests.blackbox',
35
'bzrlib.tests.branch_implementations',
36
'bzrlib.tests.bzrdir_implementations',
37
'bzrlib.tests.interrepository_implementations',
38
'bzrlib.tests.interversionedfile_implementations',
39
'bzrlib.tests.repository_implementations',
40
'bzrlib.tests.revisionstore_implementations',
41
'bzrlib.tests.workingtree_implementations',
43
'bzrlib.transport.http',
46
'bzrlib.util.configobj',
47
'bzrlib.util.effbot.org',
48
'bzrlib.util.elementtree',
53
######################################################################
54
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
55
# including bzrlib.help
61
version_info = sys.version_info
62
except AttributeError:
63
version_info = 1, 5 # 1.5 or older
65
REINVOKE = "__BZR_REINVOKE"
67
KNOWN_PYTHONS = ('python2.4',)
69
if version_info < NEED_VERS:
70
if not os.environ.has_key(REINVOKE):
71
# mutating os.environ doesn't work in old Pythons
72
os.putenv(REINVOKE, "1")
73
for python in KNOWN_PYTHONS:
75
os.execvp(python, [python] + sys.argv)
78
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
79
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
81
if hasattr(os, "unsetenv"):
3
# This is an installation script for bzr. Run it with
4
# './setup.py install', or
5
# './setup.py --help' for more options
85
7
from distutils.core import setup
86
from distutils.command.install_scripts import install_scripts
87
from distutils.command.build import build
89
###############################
90
# Overridden distutils actions
91
###############################
93
class my_install_scripts(install_scripts):
94
""" Customized install_scripts distutils action.
95
Create bzr.bat for win32.
101
install_scripts.run(self) # standard action
103
if sys.platform == "win32":
105
scripts_dir = self.install_dir
106
script_path = self._quoted_path(os.path.join(scripts_dir,
108
python_exe = self._quoted_path(sys.executable)
109
args = self._win_batch_args()
110
batch_str = "@%s %s %s" % (python_exe, script_path, args)
111
batch_path = script_path + ".bat"
112
f = file(batch_path, "w")
115
print "Created:", batch_path
117
print "ERROR: Unable to create %s: %s" % (batch_path, e)
119
def _quoted_path(self, path):
121
return '"' + path + '"'
125
def _win_batch_args(self):
129
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
130
#/class my_install_scripts
133
class bzr_build(build):
134
"""Customized build distutils action.
141
generate_docs.main(argv=["bzr", "man"])
144
########################
146
########################
148
def get_bzr_version():
150
return bzrlib.__version__
153
if 'bdist_wininst' in sys.argv:
156
docs = glob.glob('doc/*.htm') + ['doc/default.css']
157
# python's distutils-based win32 installer
158
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
159
# install the txt files from bzrlib.doc.api.
160
'package_data': {'bzrlib': ['doc/api/*.txt']},
162
'data_files': [('Doc/Bazaar', docs)],
165
ARGS.update(META_INFO)
166
ARGS.update({'version': get_bzr_version()})
171
elif 'py2exe' in sys.argv:
175
# pick real bzr version
179
for i in bzrlib.version_info[:4]:
184
version_number.append(str(i))
185
version_str = '.'.join(version_number)
187
target = py2exe.build_exe.Target(script = "bzr",
189
icon_resources = [(0,'bzr.ico')],
190
name = META_INFO['name'],
191
version = version_str,
192
description = META_INFO['description'],
193
author = META_INFO['author'],
194
copyright = "(c) Canonical Ltd, 2005-2006",
195
company_name = "Canonical Ltd.",
196
comments = META_INFO['description'],
198
options_list = {"py2exe": {"packages": BZRLIB['packages'] +
200
"excludes": ["Tkinter", "medusa"],
201
"dist_dir": "win32_bzr.exe",
204
setup(options=options_list,
206
'tools/win32/bzr_postinstall.py',
208
zipfile='lib/library.zip')
212
ARGS = {'scripts': ['bzr'],
213
'data_files': [('man/man1', ['bzr.1'])],
214
# install the txt files from bzrlib.doc.api.
215
'package_data': {'bzrlib': ['doc/api/*.txt']},
216
'cmdclass': {'build': bzr_build,
217
'install_scripts': my_install_scripts,
221
ARGS.update(META_INFO)
222
ARGS.update({'version': get_bzr_version()})
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',