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@lists.canonical.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
######################################################################
7
37
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
8
38
# including bzrlib.help
13
41
version_info = sys.version_info
14
42
except AttributeError:
27
55
os.execvp(python, [python] + sys.argv)
30
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
31
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
58
sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
59
sys.stderr.write(" (need %d.%d or later)" % NEED_VERS)
60
sys.stderr.write('\n')
33
if hasattr(os, "unsetenv"):
62
if getattr(os, "unsetenv", None) is not None:
34
63
os.unsetenv(REINVOKE)
66
def get_bzrlib_packages():
67
"""Recurse through the bzrlib directory, and extract the package names"""
70
base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
71
for root, dirs, files in os.walk(base_path):
72
if '__init__.py' in files:
73
assert root.startswith(base_path)
74
# Get just the path below bzrlib
75
package_path = root[len(base_path):]
76
# Remove leading and trailing slashes
77
package_path = package_path.strip('\\/')
79
package_name = 'bzrlib'
81
package_name = ('bzrlib.' +
82
package_path.replace('/', '.').replace('\\', '.'))
83
packages.append(package_name)
84
return sorted(packages)
87
BZRLIB['packages'] = get_bzrlib_packages()
37
90
from distutils.core import setup
38
91
from distutils.command.install_scripts import install_scripts
39
92
from distutils.command.build import build
144
generate_docs.main(argv=["bzr", "man"])
79
147
########################
81
149
########################
86
author_email='mbp@sourcefrog.net',
87
url='http://www.bazaar-ng.org/',
88
description='Friendly distributed version control system',
95
'bzrlib.tests.blackbox',
99
'bzrlib.util.elementtree',
100
'bzrlib.util.effbot.org',
101
'bzrlib.util.configobj',
104
cmdclass={'install_scripts': my_install_scripts, 'build': bzr_build},
105
data_files=[('man/man1', ['bzr.1'])],
151
command_classes = {'install_scripts': my_install_scripts,
153
from distutils import log
154
from distutils.errors import CCompilerError, DistutilsPlatformError
155
from distutils.extension import Extension
158
from Pyrex.Distutils import build_ext
161
# try to build the extension from the prior generated source.
163
print ("The python package 'Pyrex' is not available."
164
" If the .c files are available,")
165
print ("they will be built,"
166
" but modifying the .pyx files will not rebuild them.")
168
from distutils.command.build_ext import build_ext
173
class build_ext_if_possible(build_ext):
178
except DistutilsPlatformError, e:
180
log.warn('Extensions cannot be built, '
181
'will use the Python versions instead')
183
def build_extension(self, ext):
185
build_ext.build_extension(self, ext)
186
except CCompilerError:
187
log.warn('Building of "%s" extension failed, '
188
'will use the Python version instead' % (ext.name,))
191
# Override the build_ext if we have Pyrex available
192
command_classes['build_ext'] = build_ext_if_possible
193
unavailable_files = []
196
def add_pyrex_extension(module_name, **kwargs):
197
"""Add a pyrex module to build.
199
This will use Pyrex to auto-generate the .c file if it is available.
200
Otherwise it will fall back on the .c file. If the .c file is not
201
available, it will warn, and not add anything.
203
You can pass any extra options to Extension through kwargs. One example is
206
:param module_name: The python path to the module. This will be used to
207
determine the .pyx and .c files to use.
209
path = module_name.replace('.', '/')
210
pyrex_name = path + '.pyx'
213
ext_modules.append(Extension(module_name, [pyrex_name]))
215
if not os.path.isfile(c_name):
216
unavailable_files.append(c_name)
218
ext_modules.append(Extension(module_name, [c_name]))
221
add_pyrex_extension('bzrlib._dirstate_helpers_c')
222
add_pyrex_extension('bzrlib._knit_load_data_c')
223
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
226
if unavailable_files:
227
print 'C extension(s) not found:'
228
print ' %s' % ('\n '.join(unavailable_files),)
229
print 'The python versions will be used instead.'
233
if 'bdist_wininst' in sys.argv:
236
for root, dirs, files in os.walk('doc'):
239
if os.path.splitext(f)[1] in ('.html', '.css'):
240
r.append(os.path.join(root, f))
244
target = os.path.join('Doc\\Bazaar', relative)
246
target = 'Doc\\Bazaar'
247
docs.append((target, r))
250
# python's distutils-based win32 installer
251
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
252
'ext_modules': ext_modules,
254
'data_files': find_docs(),
255
# for building pyrex extensions
256
'cmdclass': {'build_ext': build_ext_if_possible},
259
ARGS.update(META_INFO)
261
ARGS.update(PKG_DATA)
265
elif 'py2exe' in sys.argv:
269
# pick real bzr version
273
for i in bzrlib.version_info[:4]:
278
version_number.append(str(i))
279
version_str = '.'.join(version_number)
281
target = py2exe.build_exe.Target(script = "bzr",
283
icon_resources = [(0,'bzr.ico')],
284
name = META_INFO['name'],
285
version = version_str,
286
description = META_INFO['description'],
287
author = META_INFO['author'],
288
copyright = "(c) Canonical Ltd, 2005-2007",
289
company_name = "Canonical Ltd.",
290
comments = META_INFO['description'],
293
additional_packages = []
294
if sys.version.startswith('2.4'):
295
# adding elementtree package
296
additional_packages.append('elementtree')
297
elif sys.version.startswith('2.5'):
298
additional_packages.append('xml.etree')
301
warnings.warn('Unknown Python version.\n'
302
'Please check setup.py script for compatibility.')
303
# email package from std python library use lazy import,
304
# so we need to explicitly add all package
305
additional_packages.append('email')
307
options_list = {"py2exe": {"packages": BZRLIB['packages'] +
309
"excludes": ["Tkinter", "medusa", "tools"],
310
"dist_dir": "win32_bzr.exe",
313
setup(options=options_list,
315
'tools/win32/bzr_postinstall.py',
317
zipfile='lib/library.zip')
320
# ad-hoc for easy_install
322
if not 'bdist_egg' in sys.argv:
323
# generate and install bzr.1 only with plain install, not easy_install one
324
DATA_FILES = [('man/man1', ['bzr.1'])]
327
ARGS = {'scripts': ['bzr'],
328
'data_files': DATA_FILES,
329
'cmdclass': command_classes,
330
'ext_modules': ext_modules,
333
ARGS.update(META_INFO)
335
ARGS.update(PKG_DATA)