76
144
import generate_docs
77
145
generate_docs.main(argv=["bzr", "man"])
79
148
########################
81
150
########################
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.
152
command_classes = {'install_scripts': my_install_scripts,
154
from distutils import log
155
from distutils.errors import CCompilerError, DistutilsPlatformError
156
from distutils.extension import Extension
159
from Pyrex.Distutils import build_ext
162
# try to build the extension from the prior generated source.
164
print ("The python package 'Pyrex' is not available."
165
" If the .c files are available,")
166
print ("they will be built,"
167
" but modifying the .pyx files will not rebuild them.")
169
from distutils.command.build_ext import build_ext
174
class build_ext_if_possible(build_ext):
179
except DistutilsPlatformError, e:
181
log.warn('Extensions cannot be built, '
182
'will use the Python versions instead')
184
def build_extension(self, ext):
186
build_ext.build_extension(self, ext)
187
except CCompilerError:
188
log.warn('Building of "%s" extension failed, '
189
'will use the Python version instead' % (ext.name,))
192
# Override the build_ext if we have Pyrex available
193
command_classes['build_ext'] = build_ext_if_possible
194
unavailable_files = []
197
def add_pyrex_extension(module_name, **kwargs):
198
"""Add a pyrex module to build.
200
This will use Pyrex to auto-generate the .c file if it is available.
201
Otherwise it will fall back on the .c file. If the .c file is not
202
available, it will warn, and not add anything.
204
You can pass any extra options to Extension through kwargs. One example is
207
:param module_name: The python path to the module. This will be used to
208
determine the .pyx and .c files to use.
210
path = module_name.replace('.', '/')
211
pyrex_name = path + '.pyx'
214
ext_modules.append(Extension(module_name, [pyrex_name]))
216
if not os.path.isfile(c_name):
217
unavailable_files.append(c_name)
219
ext_modules.append(Extension(module_name, [c_name]))
222
add_pyrex_extension('bzrlib._dirstate_helpers_c')
223
add_pyrex_extension('bzrlib._knit_load_data_c')
224
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
227
if unavailable_files:
228
print 'C extension(s) not found:'
229
print ' %s' % ('\n '.join(unavailable_files),)
230
print 'The python versions will be used instead.'
234
if 'bdist_wininst' in sys.argv:
237
for root, dirs, files in os.walk('doc'):
240
if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
241
or f == 'quick-start-summary.svg'):
242
r.append(os.path.join(root, f))
246
target = os.path.join('Doc\\Bazaar', relative)
248
target = 'Doc\\Bazaar'
249
docs.append((target, r))
252
# python's distutils-based win32 installer
253
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
254
'ext_modules': ext_modules,
256
'data_files': find_docs(),
257
# for building pyrex extensions
258
'cmdclass': {'build_ext': build_ext_if_possible},
261
ARGS.update(META_INFO)
263
ARGS.update(PKG_DATA)
267
elif 'py2exe' in sys.argv:
272
# pick real bzr version
276
for i in bzrlib.version_info[:4]:
281
version_number.append(str(i))
282
version_str = '.'.join(version_number)
284
target = py2exe.build_exe.Target(script = "bzr",
286
icon_resources = [(0,'bzr.ico')],
287
name = META_INFO['name'],
288
version = version_str,
289
description = META_INFO['description'],
290
author = META_INFO['author'],
291
copyright = "(c) Canonical Ltd, 2005-2007",
292
company_name = "Canonical Ltd.",
293
comments = META_INFO['description'],
296
packages = BZRLIB['packages']
297
packages.remove('bzrlib')
298
packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
300
for i in glob.glob('bzrlib\\*.py'):
301
module = i[:-3].replace('\\', '.')
302
if module.endswith('__init__'):
303
module = module[:-len('__init__')]
304
includes.append(module)
306
additional_packages = set()
307
if sys.version.startswith('2.4'):
308
# adding elementtree package
309
additional_packages.add('elementtree')
310
elif sys.version.startswith('2.5'):
311
additional_packages.add('xml.etree')
314
warnings.warn('Unknown Python version.\n'
315
'Please check setup.py script for compatibility.')
316
# email package from std python library use lazy import,
317
# so we need to explicitly add all package
318
additional_packages.add('email')
320
# text files for help topis
321
text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
322
topics_files = [('lib/help_topics/en', text_topics)]
326
for root, dirs, files in os.walk('bzrlib/plugins'):
329
if not i.endswith('.py'):
331
if i == '__init__.py' and root == 'bzrlib/plugins':
333
x.append(os.path.join(root, i))
335
target_dir = root[len('bzrlib/'):] # install to 'plugins/...'
336
plugins_files.append((target_dir, x))
337
# find modules for built-in plugins
338
import tools.package_mf
339
mf = tools.package_mf.CustomModuleFinder()
340
mf.run_package('bzrlib/plugins')
341
packs, mods = mf.get_result()
342
additional_packages.update(packs)
344
options_list = {"py2exe": {"packages": packages + list(additional_packages),
345
"includes": includes + mods,
346
"excludes": ["Tkinter", "medusa", "tools"],
347
"dist_dir": "win32_bzr.exe",
350
setup(options=options_list,
352
'tools/win32/bzr_postinstall.py',
354
zipfile='lib/library.zip',
355
data_files=topics_files + plugins_files,
359
# ad-hoc for easy_install
361
if not 'bdist_egg' in sys.argv:
362
# generate and install bzr.1 only with plain install, not easy_install one
363
DATA_FILES = [('man/man1', ['bzr.1'])]
366
ARGS = {'scripts': ['bzr'],
367
'data_files': DATA_FILES,
368
'cmdclass': command_classes,
369
'ext_modules': ext_modules,
372
ARGS.update(META_INFO)
374
ARGS.update(PKG_DATA)