39
37
'version': bzrlib.__version__,
40
38
'author': 'Canonical Ltd',
41
39
'author_email': 'bazaar@lists.canonical.com',
42
'url': 'http://bazaar.canonical.com/',
40
'url': 'http://www.bazaar-vcs.org/',
43
41
'description': 'Friendly distributed version control system',
44
42
'license': 'GNU GPL v2',
45
43
'download_url': 'https://launchpad.net/bzr/+download',
67
65
'package_data': {'bzrlib': ['doc/api/*.txt',
68
66
'tests/test_patches_data/*',
69
67
'help_topics/en/*.txt',
70
'tests/ssl_certs/ca.crt',
71
68
'tests/ssl_certs/server_without_pass.key',
72
69
'tests/ssl_certs/server_with_pass.key',
73
'tests/ssl_certs/server.crt',
70
'tests/ssl_certs/server.crt'
77
for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
78
langfile = filepath[len("bzrlib/locale/"):]
79
targetpath = os.path.dirname(os.path.join("share/locale", langfile))
80
I18N_FILES.append((targetpath, [filepath]))
82
75
def get_bzrlib_packages():
83
76
"""Recurse through the bzrlib directory, and extract the package names"""
132
125
f = file(batch_path, "w")
133
126
f.write(batch_str)
135
print("Created: %s" % batch_path)
137
e = sys.exc_info()[1]
138
print("ERROR: Unable to create %s: %s" % (batch_path, e))
128
print "Created:", batch_path
130
print "ERROR: Unable to create %s: %s" % (batch_path, e)
140
132
def _quoted_path(self, path):
173
161
########################
175
from bzrlib.bzr_distutils import build_mo
177
163
command_classes = {'install_scripts': my_install_scripts,
179
'build_mo': build_mo,
181
165
from distutils import log
182
166
from distutils.errors import CCompilerError, DistutilsPlatformError
183
167
from distutils.extension import Extension
171
from Pyrex.Distutils import build_ext
172
from Pyrex.Compiler.Version import version as pyrex_version
174
print "No Pyrex, trying Cython..."
187
175
from Cython.Distutils import build_ext
188
176
from Cython.Compiler.Version import version as pyrex_version
190
print("No Cython, trying Pyrex...")
191
from Pyrex.Distutils import build_ext
192
from Pyrex.Compiler.Version import version as pyrex_version
193
177
except ImportError:
194
178
have_pyrex = False
195
179
# try to build the extension from the prior generated source.
197
print("The python package 'Pyrex' is not available."
198
" If the .c files are available,")
199
print("they will be built,"
200
" but modifying the .pyx files will not rebuild them.")
181
print ("The python package 'Pyrex' is not available."
182
" If the .c files are available,")
183
print ("they will be built,"
184
" but modifying the .pyx files will not rebuild them.")
202
186
from distutils.command.build_ext import build_ext
204
188
have_pyrex = True
205
pyrex_version_info = tuple(map(int, pyrex_version.rstrip("+").split('.')))
208
191
class build_ext_if_possible(build_ext):
298
280
add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
299
281
libraries=['Ws2_32'])
300
282
add_pyrex_extension('bzrlib._walkdirs_win32')
302
if have_pyrex and pyrex_version_info[:3] == (0,9,4):
285
if have_pyrex and pyrex_version == '0.9.4.1':
303
286
# Pyrex 0.9.4.1 fails to compile this extension correctly
304
287
# The code it generates re-uses a "local" pointer and
305
288
# calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
306
289
# which is NULL safe with PY_DECREF which is not.)
307
# <https://bugs.launchpad.net/bzr/+bug/449372>
308
# <https://bugs.launchpad.net/bzr/+bug/276868>
309
print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
310
print('your version of pyrex "%s". Please upgrade your pyrex'
312
print('install. For now, the non-compiled (python) version will')
313
print('be used instead.')
290
print 'Cannot build extension "bzrlib._dirstate_helpers_pyx" using'
291
print 'your version of pyrex "%s". Please upgrade your pyrex' % (
293
print 'install. For now, the non-compiled (python) version will'
294
print 'be used instead.'
315
296
add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
316
297
add_pyrex_extension('bzrlib._readdir_pyx')
317
add_pyrex_extension('bzrlib._chk_map_pyx')
299
add_pyrex_extension('bzrlib._chk_map_pyx', libraries=[z_lib])
318
300
ext_modules.append(Extension('bzrlib._patiencediff_c',
319
301
['bzrlib/_patiencediff_c.c']))
320
if have_pyrex and pyrex_version_info < (0, 9, 6, 3):
322
print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
324
print('and static_tuple extensions.')
325
print('Please upgrade to at least Pyrex 0.9.6.3')
327
# TODO: Should this be a fatal error?
329
# We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
331
add_pyrex_extension('bzrlib._simple_set_pyx')
332
ext_modules.append(Extension('bzrlib._static_tuple_c',
333
['bzrlib/_static_tuple_c.c']))
302
add_pyrex_extension('bzrlib._simple_set_pyx')
303
ext_modules.append(Extension('bzrlib._static_tuple_c',
304
['bzrlib/_static_tuple_c.c']))
334
305
add_pyrex_extension('bzrlib._btree_serializer_pyx')
337
308
if unavailable_files:
338
print('C extension(s) not found:')
339
print(' %s' % ('\n '.join(unavailable_files),))
340
print('The python versions will be used instead.')
309
print 'C extension(s) not found:'
310
print ' %s' % ('\n '.join(unavailable_files),)
311
print 'The python versions will be used instead.'
344
315
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
408
379
# ditto for the tbzrcommand tool
409
380
tbzrcommand = dict(
410
381
script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
411
icon_resources = icon_resources,
412
other_resources = other_resources,
382
icon_resources = [(0,'bzr.ico')],
414
384
console_targets.append(tbzrcommand)
415
385
tbzrcommandw = tbzrcommand.copy()
430
400
def get_qbzr_py2exe_info(includes, excludes, packages, data_files):
431
401
# PyQt4 itself still escapes the plugin detection code for some reason...
432
includes.append('PyQt4.QtCore')
433
includes.append('PyQt4.QtGui')
402
packages.append('PyQt4')
403
excludes.append('PyQt4.elementtree.ElementTree')
434
404
includes.append('sip') # extension module required for Qt.
435
405
packages.append('pygments') # colorizer for qbzr
436
406
packages.append('docutils') # html formatting
437
407
includes.append('win32event') # for qsubprocess stuff
408
# but we can avoid many Qt4 Dlls.
410
"""QtAssistantClient4.dll QtCLucene4.dll QtDesigner4.dll
411
QtHelp4.dll QtNetwork4.dll QtOpenGL4.dll QtScript4.dll
412
QtSql4.dll QtTest4.dll QtWebKit4.dll QtXml4.dll
413
qscintilla2.dll""".split())
438
414
# the qt binaries might not be on PATH...
439
415
# They seem to install to a place like C:\Python25\PyQt4\*
440
416
# Which is not the same as C:\Python25\Lib\site-packages\PyQt4
480
456
def get_svn_py2exe_info(includes, excludes, packages):
481
457
packages.append('subvertpy')
482
packages.append('sqlite3')
485
def get_git_py2exe_info(includes, excludes, packages):
486
packages.append('dulwich')
489
def get_fastimport_py2exe_info(includes, excludes, packages):
490
# This is the python-fastimport package, not to be confused with the
491
# bzr-fastimport plugin.
492
packages.append('fastimport')
495
460
if 'bdist_wininst' in sys.argv:
553
518
install_data.run(self)
555
520
py2exe = self.distribution.get_command_obj('py2exe', False)
556
# GZ 2010-04-19: Setup has py2exe.optimize as 2, but give plugins
557
# time before living with docstring stripping
521
optimize = py2exe.optimize
559
522
compile_names = [f for f in self.outfiles if f.endswith('.py')]
560
# Round mtime to nearest even second so that installing on a FAT
561
# filesystem bytecode internal and script timestamps will match
562
for f in compile_names:
563
mtime = os.stat(f).st_mtime
564
remainder = mtime % 2
567
os.utime(f, (mtime, mtime))
568
523
byte_compile(compile_names,
569
524
optimize=optimize,
570
525
force=self.force, prefix=self.install_dir,
571
526
dry_run=self.dry_run)
572
self.outfiles.extend([f + 'o' for f in compile_names])
531
self.outfiles.extend([f + suffix for f in compile_names])
573
532
# end of class install_data_with_bytecompile
575
534
target = py2exe.build_exe.Target(script = "bzr",
579
538
version = version_str,
580
539
description = META_INFO['description'],
581
540
author = META_INFO['author'],
582
copyright = "(c) Canonical Ltd, 2005-2010",
541
copyright = "(c) Canonical Ltd, 2005-2009",
583
542
company_name = "Canonical Ltd.",
584
543
comments = META_INFO['description'],
586
gui_target = copy.copy(target)
587
gui_target.dest_base = "bzrw"
589
546
packages = BZRLIB['packages']
590
547
packages.remove('bzrlib')
652
609
excludes.extend(["bzrlib.plugins." + d for d in dirs])
655
# Throw away files we don't want packaged. Note that plugins may
656
# have data files with all sorts of extensions so we need to
657
# be conservative here about what we ditch.
658
ext = os.path.splitext(i)[1]
659
if ext.endswith('~') or ext in [".pyc", ".swp"]:
612
if os.path.splitext(i)[1] not in [".py", ".pyd", ".dll", ".mo"]:
661
614
if i == '__init__.py' and root == 'bzrlib/plugins':
675
628
console_targets = [target,
676
629
'tools/win32/bzr_postinstall.py',
678
gui_targets = [gui_target]
679
data_files = topics_files + plugins_files + I18N_FILES
632
data_files = topics_files + plugins_files
681
634
if 'qbzr' in plugins:
682
635
get_qbzr_py2exe_info(includes, excludes, packages, data_files)
684
637
if 'svn' in plugins:
685
638
get_svn_py2exe_info(includes, excludes, packages)
688
get_git_py2exe_info(includes, excludes, packages)
690
if 'fastimport' in plugins:
691
get_fastimport_py2exe_info(includes, excludes, packages)
693
640
if "TBZR" in os.environ:
694
641
# TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
695
642
# TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
714
661
# print this warning to stderr as output is redirected, so it is seen
715
662
# at build time. Also to stdout so it appears in the log
716
663
for f in (sys.stderr, sys.stdout):
717
f.write("Skipping TBZR binaries - "
718
"please set TBZR to a directory to enable\n")
665
"Skipping TBZR binaries - please set TBZR to a directory to enable"
720
667
# MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
722
dll_excludes.extend(["MSWSOCK.dll",
669
dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
727
670
options_list = {"py2exe": {"packages": packages + list(additional_packages),
728
671
"includes": includes,
729
672
"excludes": excludes,
730
673
"dll_excludes": dll_excludes,
731
674
"dist_dir": "win32_bzr.exe",
733
"custom_boot_script":
734
"tools/win32/py2exe_boot_common.py",
738
# We want the libaray.zip to have optimize = 2, but the exe to have
739
# optimize = 1, so that .py files that get compilied at run time
740
# (e.g. user installed plugins) dont have their doc strings removed.
741
class py2exe_no_oo_exe(py2exe.build_exe.py2exe):
742
def build_executable(self, *args, **kwargs):
744
py2exe.build_exe.py2exe.build_executable(self, *args, **kwargs)
747
if __name__ == '__main__':
748
command_classes['install_data'] = install_data_with_bytecompile
749
command_classes['py2exe'] = py2exe_no_oo_exe
750
setup(options=options_list,
751
console=console_targets,
753
zipfile='lib/library.zip',
754
data_files=data_files,
755
cmdclass=command_classes,
679
setup(options=options_list,
680
console=console_targets,
682
zipfile='lib/library.zip',
683
data_files=data_files,
684
cmdclass={'install_data': install_data_with_bytecompile},
759
688
# ad-hoc for easy_install