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
15
# META INFORMATION FOR SETUP
17
META_INFO = {'name': 'bzr',
18
'version': bzrlib.__version__,
19
'author': 'Canonical Ltd',
20
'author_email': 'bazaar-ng@lists.ubuntu.com',
21
'url': 'http://www.bazaar-vcs.org/',
22
'description': 'Friendly distributed version control system',
23
'license': 'GNU GPL v2',
26
# The list of packages is automatically generated later. Add other things
27
# that are part of BZRLIB here.
30
PKG_DATA = {# install files from selftest suite
31
'package_data': {'bzrlib': ['doc/api/*.txt',
32
'tests/test_patches_data/*',
36
######################################################################
37
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
38
# including bzrlib.help
41
version_info = sys.version_info
42
except AttributeError:
43
version_info = 1, 5 # 1.5 or older
45
REINVOKE = "__BZR_REINVOKE"
47
KNOWN_PYTHONS = ('python2.4',)
49
if version_info < NEED_VERS:
50
if not os.environ.has_key(REINVOKE):
51
# mutating os.environ doesn't work in old Pythons
52
os.putenv(REINVOKE, "1")
53
for python in KNOWN_PYTHONS:
55
os.execvp(python, [python] + sys.argv)
58
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
59
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
61
if getattr(os, "unsetenv", None) is not None:
65
def get_bzrlib_packages():
66
"""Recurse through the bzrlib directory, and extract the package names"""
69
base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
70
for root, dirs, files in os.walk(base_path):
71
if '__init__.py' in files:
72
assert root.startswith(base_path)
73
# Get just the path below bzrlib
74
package_path = root[len(base_path):]
75
# Remove leading and trailing slashes
76
package_path = package_path.strip('\\/')
78
package_name = 'bzrlib'
80
package_name = ('bzrlib.' +
81
package_path.replace('/', '.').replace('\\', '.'))
82
packages.append(package_name)
83
return sorted(packages)
86
BZRLIB['packages'] = get_bzrlib_packages()
7
89
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',
90
from distutils.command.install_scripts import install_scripts
91
from distutils.command.build import build
93
###############################
94
# Overridden distutils actions
95
###############################
97
class my_install_scripts(install_scripts):
98
""" Customized install_scripts distutils action.
99
Create bzr.bat for win32.
105
install_scripts.run(self) # standard action
107
if sys.platform == "win32":
109
scripts_dir = self.install_dir
110
script_path = self._quoted_path(os.path.join(scripts_dir,
112
python_exe = self._quoted_path(sys.executable)
113
args = self._win_batch_args()
114
batch_str = "@%s %s %s" % (python_exe, script_path, args)
115
batch_path = script_path + ".bat"
116
f = file(batch_path, "w")
119
print "Created:", batch_path
121
print "ERROR: Unable to create %s: %s" % (batch_path, e)
123
def _quoted_path(self, path):
125
return '"' + path + '"'
129
def _win_batch_args(self):
133
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
134
#/class my_install_scripts
137
class bzr_build(build):
138
"""Customized build distutils action.
145
generate_docs.main(argv=["bzr", "man"])
148
########################
150
########################
152
if 'bdist_wininst' in sys.argv:
155
docs = glob.glob('doc/*.htm') + ['doc/default.css']
156
# python's distutils-based win32 installer
157
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
159
'data_files': [('Doc/Bazaar', docs)],
162
ARGS.update(META_INFO)
164
ARGS.update(PKG_DATA)
168
elif 'py2exe' in sys.argv:
172
# pick real bzr version
176
for i in bzrlib.version_info[:4]:
181
version_number.append(str(i))
182
version_str = '.'.join(version_number)
184
target = py2exe.build_exe.Target(script = "bzr",
186
icon_resources = [(0,'bzr.ico')],
187
name = META_INFO['name'],
188
version = version_str,
189
description = META_INFO['description'],
190
author = META_INFO['author'],
191
copyright = "(c) Canonical Ltd, 2005-2007",
192
company_name = "Canonical Ltd.",
193
comments = META_INFO['description'],
196
additional_packages = []
197
if sys.version.startswith('2.4'):
198
# adding elementtree package
199
additional_packages.append('elementtree')
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)