65
67
'package_data': {'bzrlib': ['doc/api/*.txt',
66
68
'tests/test_patches_data/*',
67
69
'help_topics/en/*.txt',
70
'tests/ssl_certs/ca.crt',
71
'tests/ssl_certs/server_without_pass.key',
72
'tests/ssl_certs/server_with_pass.key',
73
'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]))
72
82
def get_bzrlib_packages():
73
83
"""Recurse through the bzrlib directory, and extract the package names"""
157
173
########################
175
from bzrlib.bzr_distutils import build_mo
159
177
command_classes = {'install_scripts': my_install_scripts,
179
'build_mo': build_mo,
161
181
from distutils import log
162
182
from distutils.errors import CCompilerError, DistutilsPlatformError
163
183
from distutils.extension import Extension
166
from Pyrex.Distutils import build_ext
187
from Cython.Distutils import build_ext
188
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
167
193
except ImportError:
168
194
have_pyrex = False
169
195
# try to build the extension from the prior generated source.
171
print ("The python package 'Pyrex' is not available."
172
" If the .c files are available,")
173
print ("they will be built,"
174
" but modifying the .pyx files will not rebuild them.")
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.")
176
202
from distutils.command.build_ext import build_ext
178
204
have_pyrex = True
179
from Pyrex.Compiler.Version import version as pyrex_version
205
pyrex_version_info = tuple(map(int, pyrex_version.rstrip("+").split('.')))
182
208
class build_ext_if_possible(build_ext):
259
286
define_macros=define_macros, libraries=libraries))
262
add_pyrex_extension('bzrlib._btree_serializer_c')
289
add_pyrex_extension('bzrlib._annotator_pyx')
290
add_pyrex_extension('bzrlib._bencode_pyx')
291
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
263
292
add_pyrex_extension('bzrlib._groupcompress_pyx',
264
293
extra_source=['bzrlib/diff-delta.c'])
265
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
266
add_pyrex_extension('bzrlib._knit_load_data_c')
267
add_pyrex_extension('bzrlib._chk_map_pyx', libraries=['z'])
294
add_pyrex_extension('bzrlib._knit_load_data_pyx')
295
add_pyrex_extension('bzrlib._known_graph_pyx')
296
add_pyrex_extension('bzrlib._rio_pyx')
268
297
if sys.platform == 'win32':
269
add_pyrex_extension('bzrlib._dirstate_helpers_c',
298
add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
270
299
libraries=['Ws2_32'])
271
300
add_pyrex_extension('bzrlib._walkdirs_win32')
273
if have_pyrex and pyrex_version == '0.9.4.1':
302
if have_pyrex and pyrex_version_info[:3] == (0,9,4):
274
303
# Pyrex 0.9.4.1 fails to compile this extension correctly
275
304
# The code it generates re-uses a "local" pointer and
276
305
# calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
277
306
# which is NULL safe with PY_DECREF which is not.)
278
print 'Cannot build extension "bzrlib._dirstate_helpers_c" using'
279
print 'your version of pyrex "%s". Please upgrade your pyrex' % (
281
print 'install. For now, the non-compiled (python) version will'
282
print 'be used instead.'
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.')
284
add_pyrex_extension('bzrlib._dirstate_helpers_c')
315
add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
285
316
add_pyrex_extension('bzrlib._readdir_pyx')
286
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
317
add_pyrex_extension('bzrlib._chk_map_pyx')
318
ext_modules.append(Extension('bzrlib._patiencediff_c',
319
['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']))
334
add_pyrex_extension('bzrlib._btree_serializer_pyx')
289
337
if unavailable_files:
290
print 'C extension(s) not found:'
291
print ' %s' % ('\n '.join(unavailable_files),)
292
print 'The python versions will be used instead.'
338
print('C extension(s) not found:')
339
print(' %s' % ('\n '.join(unavailable_files),))
340
print('The python versions will be used instead.')
296
344
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
387
422
console_targets.append(tracer)
389
424
# The C++ implemented shell extensions.
390
dist_dir = os.path.join(tbzr_root, "shellext", "cpp", "tbzrshellext",
425
dist_dir = os.path.join(tbzr_root, "shellext", "build")
392
426
data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x86.dll')]))
393
427
data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x64.dll')]))
396
def get_qbzr_py2exe_info(includes, excludes, packages):
430
def get_qbzr_py2exe_info(includes, excludes, packages, data_files):
397
431
# PyQt4 itself still escapes the plugin detection code for some reason...
398
packages.append('PyQt4')
399
excludes.append('PyQt4.elementtree.ElementTree')
432
includes.append('PyQt4.QtCore')
433
includes.append('PyQt4.QtGui')
434
includes.append('PyQt4.QtTest')
400
435
includes.append('sip') # extension module required for Qt.
401
436
packages.append('pygments') # colorizer for qbzr
402
437
packages.append('docutils') # html formatting
403
# but we can avoid many Qt4 Dlls.
405
"""QtAssistantClient4.dll QtCLucene4.dll QtDesigner4.dll
406
QtHelp4.dll QtNetwork4.dll QtOpenGL4.dll QtScript4.dll
407
QtSql4.dll QtTest4.dll QtWebKit4.dll QtXml4.dll
408
qscintilla2.dll""".split())
438
includes.append('win32event') # for qsubprocess stuff
409
439
# the qt binaries might not be on PATH...
410
qt_dir = os.path.join(sys.prefix, "PyQt4", "bin")
411
path = os.environ.get("PATH","")
412
if qt_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
413
os.environ["PATH"] = path + os.pathsep + qt_dir
440
# They seem to install to a place like C:\Python25\PyQt4\*
441
# Which is not the same as C:\Python25\Lib\site-packages\PyQt4
442
pyqt_dir = os.path.join(sys.prefix, "PyQt4")
443
pyqt_bin_dir = os.path.join(pyqt_dir, "bin")
444
if os.path.isdir(pyqt_bin_dir):
445
path = os.environ.get("PATH", "")
446
if pyqt_bin_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
447
os.environ["PATH"] = path + os.pathsep + pyqt_bin_dir
448
# also add all imageformat plugins to distribution
449
# We will look in 2 places, dirname(PyQt4.__file__) and pyqt_dir
450
base_dirs_to_check = []
451
if os.path.isdir(pyqt_dir):
452
base_dirs_to_check.append(pyqt_dir)
458
pyqt4_base_dir = os.path.dirname(PyQt4.__file__)
459
if pyqt4_base_dir != pyqt_dir:
460
base_dirs_to_check.append(pyqt4_base_dir)
461
if not base_dirs_to_check:
462
log.warn("Can't find PyQt4 installation -> not including imageformat"
466
for base_dir in base_dirs_to_check:
467
plug_dir = os.path.join(base_dir, 'plugins', 'imageformats')
468
if os.path.isdir(plug_dir):
469
for fname in os.listdir(plug_dir):
470
# Include plugin dlls, but not debugging dlls
471
fullpath = os.path.join(plug_dir, fname)
472
if fname.endswith('.dll') and not fname.endswith('d4.dll'):
473
files.append(fullpath)
475
data_files.append(('imageformats', files))
477
log.warn('PyQt4 was found, but we could not find any imageformat'
478
' plugins. Are you sure your configuration is correct?')
416
481
def get_svn_py2exe_info(includes, excludes, packages):
417
482
packages.append('subvertpy')
483
packages.append('sqlite3')
486
def get_git_py2exe_info(includes, excludes, packages):
487
packages.append('dulwich')
490
def get_fastimport_py2exe_info(includes, excludes, packages):
491
# This is the python-fastimport package, not to be confused with the
492
# bzr-fastimport plugin.
493
packages.append('fastimport')
420
496
if 'bdist_wininst' in sys.argv:
478
554
install_data.run(self)
480
556
py2exe = self.distribution.get_command_obj('py2exe', False)
481
optimize = py2exe.optimize
557
# GZ 2010-04-19: Setup has py2exe.optimize as 2, but give plugins
558
# time before living with docstring stripping
482
560
compile_names = [f for f in self.outfiles if f.endswith('.py')]
561
# Round mtime to nearest even second so that installing on a FAT
562
# filesystem bytecode internal and script timestamps will match
563
for f in compile_names:
564
mtime = os.stat(f).st_mtime
565
remainder = mtime % 2
568
os.utime(f, (mtime, mtime))
483
569
byte_compile(compile_names,
484
570
optimize=optimize,
485
571
force=self.force, prefix=self.install_dir,
486
572
dry_run=self.dry_run)
491
self.outfiles.extend([f + suffix for f in compile_names])
573
self.outfiles.extend([f + 'o' for f in compile_names])
492
574
# end of class install_data_with_bytecompile
494
576
target = py2exe.build_exe.Target(script = "bzr",
588
676
console_targets = [target,
589
677
'tools/win32/bzr_postinstall.py',
593
data_files = topics_files + plugins_files
679
gui_targets = [gui_target]
680
data_files = topics_files + plugins_files + I18N_FILES
595
682
if 'qbzr' in plugins:
596
get_qbzr_py2exe_info(includes, excludes, packages)
683
get_qbzr_py2exe_info(includes, excludes, packages, data_files)
598
685
if 'svn' in plugins:
599
686
get_svn_py2exe_info(includes, excludes, packages)
689
get_git_py2exe_info(includes, excludes, packages)
691
if 'fastimport' in plugins:
692
get_fastimport_py2exe_info(includes, excludes, packages)
601
694
if "TBZR" in os.environ:
602
695
# TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
603
696
# TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
604
697
# can be downloaded from (username=guest, blank password):
605
# http://tortoisesvn.tigris.org/svn/tortoisesvn/TortoiseOverlays/version-1.0.4/bin/TortoiseOverlays-1.0.4.11886-win32.msi
698
# http://tortoisesvn.tigris.org/svn/tortoisesvn/TortoiseOverlays
699
# look for: version-1.0.4/bin/TortoiseOverlays-1.0.4.11886-win32.msi
606
700
# Ditto for TORTOISE_OVERLAYS_MSI_X64, pointing at *-x64.msi.
607
701
for needed in ('TORTOISE_OVERLAYS_MSI_WIN32',
608
702
'TORTOISE_OVERLAYS_MSI_X64'):
703
url = ('http://guest:@tortoisesvn.tigris.org/svn/tortoisesvn'
609
705
if not os.path.isfile(os.environ.get(needed, '<nofile>')):
610
raise RuntimeError("Please set %s to the"
611
" location of the relevant TortoiseOverlays"
612
" .msi installer file" % needed)
707
"\nPlease set %s to the location of the relevant"
708
"\nTortoiseOverlays .msi installer file."
709
" The installers can be found at"
711
"\ncheck in the version-X.Y.Z/bin/ subdir" % (needed, url))
613
712
get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
614
713
gui_targets, data_files)
616
715
# print this warning to stderr as output is redirected, so it is seen
617
716
# at build time. Also to stdout so it appears in the log
618
717
for f in (sys.stderr, sys.stdout):
620
"Skipping TBZR binaries - please set TBZR to a directory to enable"
718
f.write("Skipping TBZR binaries - "
719
"please set TBZR to a directory to enable\n")
622
721
# MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
624
dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
723
dll_excludes.extend(["MSWSOCK.dll",
625
728
options_list = {"py2exe": {"packages": packages + list(additional_packages),
626
729
"includes": includes,
627
730
"excludes": excludes,
628
731
"dll_excludes": dll_excludes,
629
732
"dist_dir": "win32_bzr.exe",
734
"custom_boot_script":
735
"tools/win32/py2exe_boot_common.py",
634
setup(options=options_list,
635
console=console_targets,
637
com_server=com_targets,
638
zipfile='lib/library.zip',
639
data_files=data_files,
640
cmdclass={'install_data': install_data_with_bytecompile},
739
# We want the libaray.zip to have optimize = 2, but the exe to have
740
# optimize = 1, so that .py files that get compilied at run time
741
# (e.g. user installed plugins) dont have their doc strings removed.
742
class py2exe_no_oo_exe(py2exe.build_exe.py2exe):
743
def build_executable(self, *args, **kwargs):
745
py2exe.build_exe.py2exe.build_executable(self, *args, **kwargs)
748
if __name__ == '__main__':
749
command_classes['install_data'] = install_data_with_bytecompile
750
command_classes['py2exe'] = py2exe_no_oo_exe
751
setup(options=options_list,
752
console=console_targets,
754
zipfile='lib/library.zip',
755
data_files=data_files,
756
cmdclass=command_classes,
644
760
# ad-hoc for easy_install
646
762
if not 'bdist_egg' in sys.argv:
647
# generate and install bzr.1 only with plain install, not easy_install one
763
# generate and install bzr.1 only with plain install, not the
648
765
DATA_FILES = [('man/man1', ['bzr.1'])]
767
DATA_FILES = DATA_FILES + I18N_FILES
651
769
ARGS = {'scripts': ['bzr'],
652
770
'data_files': DATA_FILES,