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
7
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
8
# including bzrlib.help
13
version_info = sys.version_info
14
except AttributeError:
15
version_info = 1, 5 # 1.5 or older
17
REINVOKE = "__BZR_REINVOKE"
19
KNOWN_PYTHONS = ('python2.4',)
21
if version_info < NEED_VERS:
22
if not os.environ.has_key(REINVOKE):
23
# mutating os.environ doesn't work in old Pythons
24
os.putenv(REINVOKE, "1")
25
for python in KNOWN_PYTHONS:
27
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
3
"""Installation script for bzr.
5
'./setup.py install', or
6
'./setup.py --help' for more options
12
if sys.version_info < (2, 4):
13
sys.stderr.write("[ERROR] Not a supported Python version. Need 2.4+\n")
33
if hasattr(os, "unsetenv"):
19
# META INFORMATION FOR SETUP
21
META_INFO = {'name': 'bzr',
22
'version': bzrlib.__version__,
23
'author': 'Canonical Ltd',
24
'author_email': 'bazaar@lists.canonical.com',
25
'url': 'http://www.bazaar-vcs.org/',
26
'description': 'Friendly distributed version control system',
27
'license': 'GNU GPL v2',
30
# The list of packages is automatically generated later. Add other things
31
# that are part of BZRLIB here.
34
PKG_DATA = {# install files from selftest suite
35
'package_data': {'bzrlib': ['doc/api/*.txt',
36
'tests/test_patches_data/*',
37
'help_topics/en/*.txt',
42
def get_bzrlib_packages():
43
"""Recurse through the bzrlib directory, and extract the package names"""
46
base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
47
for root, dirs, files in os.walk(base_path):
48
if '__init__.py' in files:
49
assert root.startswith(base_path)
50
# Get just the path below bzrlib
51
package_path = root[len(base_path):]
52
# Remove leading and trailing slashes
53
package_path = package_path.strip('\\/')
55
package_name = 'bzrlib'
57
package_name = ('bzrlib.' +
58
package_path.replace('/', '.').replace('\\', '.'))
59
packages.append(package_name)
60
return sorted(packages)
63
BZRLIB['packages'] = get_bzrlib_packages()
37
66
from distutils.core import setup
76
119
import generate_docs
77
120
generate_docs.main(argv=["bzr", "man"])
79
123
########################
81
125
########################
86
author_email='mbp@sourcefrog.net',
87
url='http://www.bazaar-ng.org/',
88
description='Friendly distributed version control system',
96
'bzrlib.store.revision',
97
'bzrlib.store.versioned',
99
'bzrlib.tests.blackbox',
100
'bzrlib.tests.branch_implementations',
101
'bzrlib.tests.bzrdir_implementations',
102
'bzrlib.tests.interrepository_implementations',
103
'bzrlib.tests.interversionedfile_implementations',
104
'bzrlib.tests.repository_implementations',
105
'bzrlib.tests.revisionstore_implementations',
106
'bzrlib.tests.workingtree_implementations',
108
'bzrlib.transport.http',
111
'bzrlib.util.elementtree',
112
'bzrlib.util.effbot.org',
113
'bzrlib.util.configobj',
116
cmdclass={'install_scripts': my_install_scripts, 'build': bzr_build},
117
data_files=[('man/man1', ['bzr.1'])],
118
# todo: install the txt files from bzrlib.doc.api.
127
command_classes = {'install_scripts': my_install_scripts,
129
from distutils import log
130
from distutils.errors import CCompilerError, DistutilsPlatformError
131
from distutils.extension import Extension
134
from Pyrex.Distutils import build_ext
137
# try to build the extension from the prior generated source.
139
print ("The python package 'Pyrex' is not available."
140
" If the .c files are available,")
141
print ("they will be built,"
142
" but modifying the .pyx files will not rebuild them.")
144
from distutils.command.build_ext import build_ext
149
class build_ext_if_possible(build_ext):
154
except DistutilsPlatformError, e:
156
log.warn('Extensions cannot be built, '
157
'will use the Python versions instead')
159
def build_extension(self, ext):
161
build_ext.build_extension(self, ext)
162
except CCompilerError:
163
log.warn('Building of "%s" extension failed, '
164
'will use the Python version instead' % (ext.name,))
167
# Override the build_ext if we have Pyrex available
168
command_classes['build_ext'] = build_ext_if_possible
169
unavailable_files = []
172
def add_pyrex_extension(module_name, **kwargs):
173
"""Add a pyrex module to build.
175
This will use Pyrex to auto-generate the .c file if it is available.
176
Otherwise it will fall back on the .c file. If the .c file is not
177
available, it will warn, and not add anything.
179
You can pass any extra options to Extension through kwargs. One example is
182
:param module_name: The python path to the module. This will be used to
183
determine the .pyx and .c files to use.
185
path = module_name.replace('.', '/')
186
pyrex_name = path + '.pyx'
189
ext_modules.append(Extension(module_name, [pyrex_name]))
191
if not os.path.isfile(c_name):
192
unavailable_files.append(c_name)
194
ext_modules.append(Extension(module_name, [c_name]))
197
add_pyrex_extension('bzrlib._dirstate_helpers_c')
198
add_pyrex_extension('bzrlib._knit_load_data_c')
199
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
202
if unavailable_files:
203
print 'C extension(s) not found:'
204
print ' %s' % ('\n '.join(unavailable_files),)
205
print 'The python versions will be used instead.'
209
if 'bdist_wininst' in sys.argv:
212
for root, dirs, files in os.walk('doc'):
215
if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
216
or f == 'quick-start-summary.svg'):
217
r.append(os.path.join(root, f))
221
target = os.path.join('Doc\\Bazaar', relative)
223
target = 'Doc\\Bazaar'
224
docs.append((target, r))
227
# python's distutils-based win32 installer
228
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
229
'ext_modules': ext_modules,
231
'data_files': find_docs(),
232
# for building pyrex extensions
233
'cmdclass': {'build_ext': build_ext_if_possible},
236
ARGS.update(META_INFO)
238
ARGS.update(PKG_DATA)
242
elif 'py2exe' in sys.argv:
247
# pick real bzr version
251
for i in bzrlib.version_info[:4]:
256
version_number.append(str(i))
257
version_str = '.'.join(version_number)
259
target = py2exe.build_exe.Target(script = "bzr",
261
icon_resources = [(0,'bzr.ico')],
262
name = META_INFO['name'],
263
version = version_str,
264
description = META_INFO['description'],
265
author = META_INFO['author'],
266
copyright = "(c) Canonical Ltd, 2005-2007",
267
company_name = "Canonical Ltd.",
268
comments = META_INFO['description'],
271
packages = BZRLIB['packages']
272
packages.remove('bzrlib')
273
packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
275
for i in glob.glob('bzrlib\\*.py'):
276
module = i[:-3].replace('\\', '.')
277
if module.endswith('__init__'):
278
module = module[:-len('__init__')]
279
includes.append(module)
281
additional_packages = set()
282
if sys.version.startswith('2.4'):
283
# adding elementtree package
284
additional_packages.add('elementtree')
285
elif sys.version.startswith('2.5'):
286
additional_packages.add('xml.etree')
289
warnings.warn('Unknown Python version.\n'
290
'Please check setup.py script for compatibility.')
291
# email package from std python library use lazy import,
292
# so we need to explicitly add all package
293
additional_packages.add('email')
295
# text files for help topis
296
text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
297
topics_files = [('lib/help_topics/en', text_topics)]
301
for root, dirs, files in os.walk('bzrlib/plugins'):
304
if not i.endswith('.py'):
306
if i == '__init__.py' and root == 'bzrlib/plugins':
308
x.append(os.path.join(root, i))
310
target_dir = root[len('bzrlib/'):] # install to 'plugins/...'
311
plugins_files.append((target_dir, x))
312
# find modules for built-in plugins
313
import tools.package_mf
314
mf = tools.package_mf.CustomModuleFinder()
315
mf.run_package('bzrlib/plugins')
316
packs, mods = mf.get_result()
317
additional_packages.update(packs)
319
options_list = {"py2exe": {"packages": packages + list(additional_packages),
320
"includes": includes + mods,
321
"excludes": ["Tkinter", "medusa", "tools"],
322
"dist_dir": "win32_bzr.exe",
325
setup(options=options_list,
327
'tools/win32/bzr_postinstall.py',
329
zipfile='lib/library.zip',
330
data_files=topics_files + plugins_files,
334
# ad-hoc for easy_install
336
if not 'bdist_egg' in sys.argv:
337
# generate and install bzr.1 only with plain install, not easy_install one
338
DATA_FILES = [('man/man1', ['bzr.1'])]
341
ARGS = {'scripts': ['bzr'],
342
'data_files': DATA_FILES,
343
'cmdclass': command_classes,
344
'ext_modules': ext_modules,
347
ARGS.update(META_INFO)
349
ARGS.update(PKG_DATA)