37
39
'version': bzrlib.__version__,
38
40
'author': 'Canonical Ltd',
39
41
'author_email': 'bazaar@lists.canonical.com',
40
'url': 'http://www.bazaar-vcs.org/',
42
'url': 'http://bazaar.canonical.com/',
41
43
'description': 'Friendly distributed version control system',
42
44
'license': 'GNU GPL v2',
43
'download_url': 'http://bazaar-vcs.org/Download',
45
'download_url': 'https://launchpad.net/bzr/+download',
44
46
'long_description': get_long_description(),
46
48
'Development Status :: 6 - Mature',
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 tools.build_mo 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
206
_version = re.match("^[0-9.]+", pyrex_version).group(0)
207
pyrex_version_info = tuple(map(int, _version.split('.')))
182
210
class build_ext_if_possible(build_ext):
242
271
c_name = path + '.c'
243
272
define_macros = []
244
273
if sys.platform == 'win32':
245
# pyrex uses the macro WIN32 to detect the platform, even though it should
246
# be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
274
# pyrex uses the macro WIN32 to detect the platform, even though it
275
# should be using something like _WIN32 or MS_WINDOWS, oh well, we can
276
# give it the right value.
248
277
define_macros.append(('WIN32', None))
250
ext_modules.append(Extension(module_name, [pyrex_name],
251
define_macros=define_macros, libraries=libraries))
279
source = [pyrex_name]
253
281
if not os.path.isfile(c_name):
254
282
unavailable_files.append(c_name)
256
ext_modules.append(Extension(module_name, [c_name],
257
define_macros=define_macros, libraries=libraries))
260
add_pyrex_extension('bzrlib._btree_serializer_c')
286
source.extend(extra_source)
287
ext_modules.append(Extension(module_name, source,
288
define_macros=define_macros, libraries=libraries))
291
add_pyrex_extension('bzrlib._annotator_pyx')
292
add_pyrex_extension('bzrlib._bencode_pyx')
261
293
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
262
add_pyrex_extension('bzrlib._knit_load_data_c')
294
add_pyrex_extension('bzrlib._groupcompress_pyx',
295
extra_source=['bzrlib/diff-delta.c'])
296
add_pyrex_extension('bzrlib._knit_load_data_pyx')
297
add_pyrex_extension('bzrlib._known_graph_pyx')
298
add_pyrex_extension('bzrlib._rio_pyx')
263
299
if sys.platform == 'win32':
264
add_pyrex_extension('bzrlib._dirstate_helpers_c',
300
add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
265
301
libraries=['Ws2_32'])
266
302
add_pyrex_extension('bzrlib._walkdirs_win32')
268
if have_pyrex and pyrex_version == '0.9.4.1':
304
if have_pyrex and pyrex_version_info[:3] == (0,9,4):
269
305
# Pyrex 0.9.4.1 fails to compile this extension correctly
270
306
# The code it generates re-uses a "local" pointer and
271
307
# calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
272
308
# which is NULL safe with PY_DECREF which is not.)
273
print 'Cannot build extension "bzrlib._dirstate_helpers_c" using'
274
print 'your version of pyrex "%s". Please upgrade your pyrex' % (
276
print 'install. For now, the non-compiled (python) version will'
277
print 'be used instead.'
309
# <https://bugs.launchpad.net/bzr/+bug/449372>
310
# <https://bugs.launchpad.net/bzr/+bug/276868>
311
print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
312
print('your version of pyrex "%s". Please upgrade your pyrex'
314
print('install. For now, the non-compiled (python) version will')
315
print('be used instead.')
279
add_pyrex_extension('bzrlib._dirstate_helpers_c')
317
add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
280
318
add_pyrex_extension('bzrlib._readdir_pyx')
281
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
319
add_pyrex_extension('bzrlib._chk_map_pyx')
320
ext_modules.append(Extension('bzrlib._patiencediff_c',
321
['bzrlib/_patiencediff_c.c']))
322
if have_pyrex and pyrex_version_info < (0, 9, 6, 3):
324
print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
326
print('and static_tuple extensions.')
327
print('Please upgrade to at least Pyrex 0.9.6.3')
329
# TODO: Should this be a fatal error?
331
# We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
333
add_pyrex_extension('bzrlib._simple_set_pyx')
334
ext_modules.append(Extension('bzrlib._static_tuple_c',
335
['bzrlib/_static_tuple_c.c']))
336
add_pyrex_extension('bzrlib._btree_serializer_pyx')
284
339
if unavailable_files:
285
print 'C extension(s) not found:'
286
print ' %s' % ('\n '.join(unavailable_files),)
287
print 'The python versions will be used instead.'
340
print('C extension(s) not found:')
341
print(' %s' % ('\n '.join(unavailable_files),))
342
print('The python versions will be used instead.')
291
346
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
382
424
console_targets.append(tracer)
384
426
# The C++ implemented shell extensions.
385
dist_dir = os.path.join(tbzr_root, "shellext", "cpp", "tbzrshellext",
427
dist_dir = os.path.join(tbzr_root, "shellext", "build")
387
428
data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x86.dll')]))
388
429
data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x64.dll')]))
391
def get_qbzr_py2exe_info(includes, excludes, packages):
432
def get_qbzr_py2exe_info(includes, excludes, packages, data_files):
392
433
# PyQt4 itself still escapes the plugin detection code for some reason...
393
packages.append('PyQt4')
394
excludes.append('PyQt4.elementtree.ElementTree')
434
includes.append('PyQt4.QtCore')
435
includes.append('PyQt4.QtGui')
395
436
includes.append('sip') # extension module required for Qt.
396
437
packages.append('pygments') # colorizer for qbzr
397
438
packages.append('docutils') # html formatting
398
# but we can avoid many Qt4 Dlls.
400
"""QtAssistantClient4.dll QtCLucene4.dll QtDesigner4.dll
401
QtHelp4.dll QtNetwork4.dll QtOpenGL4.dll QtScript4.dll
402
QtSql4.dll QtTest4.dll QtWebKit4.dll QtXml4.dll
403
qscintilla2.dll""".split())
439
includes.append('win32event') # for qsubprocess stuff
404
440
# the qt binaries might not be on PATH...
405
qt_dir = os.path.join(sys.prefix, "PyQt4", "bin")
406
path = os.environ.get("PATH","")
407
if qt_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
408
os.environ["PATH"] = path + os.pathsep + qt_dir
441
# They seem to install to a place like C:\Python25\PyQt4\*
442
# Which is not the same as C:\Python25\Lib\site-packages\PyQt4
443
pyqt_dir = os.path.join(sys.prefix, "PyQt4")
444
pyqt_bin_dir = os.path.join(pyqt_dir, "bin")
445
if os.path.isdir(pyqt_bin_dir):
446
path = os.environ.get("PATH", "")
447
if pyqt_bin_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
448
os.environ["PATH"] = path + os.pathsep + pyqt_bin_dir
449
# also add all imageformat plugins to distribution
450
# We will look in 2 places, dirname(PyQt4.__file__) and pyqt_dir
451
base_dirs_to_check = []
452
if os.path.isdir(pyqt_dir):
453
base_dirs_to_check.append(pyqt_dir)
459
pyqt4_base_dir = os.path.dirname(PyQt4.__file__)
460
if pyqt4_base_dir != pyqt_dir:
461
base_dirs_to_check.append(pyqt4_base_dir)
462
if not base_dirs_to_check:
463
log.warn("Can't find PyQt4 installation -> not including imageformat"
467
for base_dir in base_dirs_to_check:
468
plug_dir = os.path.join(base_dir, 'plugins', 'imageformats')
469
if os.path.isdir(plug_dir):
470
for fname in os.listdir(plug_dir):
471
# Include plugin dlls, but not debugging dlls
472
fullpath = os.path.join(plug_dir, fname)
473
if fname.endswith('.dll') and not fname.endswith('d4.dll'):
474
files.append(fullpath)
476
data_files.append(('imageformats', files))
478
log.warn('PyQt4 was found, but we could not find any imageformat'
479
' plugins. Are you sure your configuration is correct?')
482
def get_svn_py2exe_info(includes, excludes, packages):
483
packages.append('subvertpy')
484
packages.append('sqlite3')
487
def get_fastimport_py2exe_info(includes, excludes, packages):
488
# This is the python-fastimport package, not to be confused with the
489
# bzr-fastimport plugin.
490
packages.append('fastimport')
411
493
if 'bdist_wininst' in sys.argv:
469
551
install_data.run(self)
471
553
py2exe = self.distribution.get_command_obj('py2exe', False)
472
optimize = py2exe.optimize
554
# GZ 2010-04-19: Setup has py2exe.optimize as 2, but give plugins
555
# time before living with docstring stripping
473
557
compile_names = [f for f in self.outfiles if f.endswith('.py')]
558
# Round mtime to nearest even second so that installing on a FAT
559
# filesystem bytecode internal and script timestamps will match
560
for f in compile_names:
561
mtime = os.stat(f).st_mtime
562
remainder = mtime % 2
565
os.utime(f, (mtime, mtime))
474
566
byte_compile(compile_names,
475
567
optimize=optimize,
476
568
force=self.force, prefix=self.install_dir,
477
569
dry_run=self.dry_run)
482
self.outfiles.extend([f + suffix for f in compile_names])
570
self.outfiles.extend([f + 'o' for f in compile_names])
483
571
# end of class install_data_with_bytecompile
485
573
target = py2exe.build_exe.Target(script = "bzr",
579
673
console_targets = [target,
580
674
'tools/win32/bzr_postinstall.py',
584
data_files = topics_files + plugins_files
676
gui_targets = [gui_target]
677
data_files = topics_files + plugins_files + I18N_FILES
586
679
if 'qbzr' in plugins:
587
get_qbzr_py2exe_info(includes, excludes, packages)
680
get_qbzr_py2exe_info(includes, excludes, packages, data_files)
683
get_svn_py2exe_info(includes, excludes, packages)
685
if 'fastimport' in plugins:
686
get_fastimport_py2exe_info(includes, excludes, packages)
589
688
if "TBZR" in os.environ:
590
689
# TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
591
690
# TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
592
691
# can be downloaded from (username=guest, blank password):
593
# http://tortoisesvn.tigris.org/svn/tortoisesvn/TortoiseOverlays/version-1.0.4/bin/TortoiseOverlays-1.0.4.11886-win32.msi
692
# http://tortoisesvn.tigris.org/svn/tortoisesvn/TortoiseOverlays
693
# look for: version-1.0.4/bin/TortoiseOverlays-1.0.4.11886-win32.msi
594
694
# Ditto for TORTOISE_OVERLAYS_MSI_X64, pointing at *-x64.msi.
595
695
for needed in ('TORTOISE_OVERLAYS_MSI_WIN32',
596
696
'TORTOISE_OVERLAYS_MSI_X64'):
697
url = ('http://guest:@tortoisesvn.tigris.org/svn/tortoisesvn'
597
699
if not os.path.isfile(os.environ.get(needed, '<nofile>')):
598
raise RuntimeError("Please set %s to the"
599
" location of the relevant TortoiseOverlays"
600
" .msi installer file" % needed)
701
"\nPlease set %s to the location of the relevant"
702
"\nTortoiseOverlays .msi installer file."
703
" The installers can be found at"
705
"\ncheck in the version-X.Y.Z/bin/ subdir" % (needed, url))
601
706
get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
602
707
gui_targets, data_files)
604
709
# print this warning to stderr as output is redirected, so it is seen
605
710
# at build time. Also to stdout so it appears in the log
606
711
for f in (sys.stderr, sys.stdout):
608
"Skipping TBZR binaries - please set TBZR to a directory to enable"
712
f.write("Skipping TBZR binaries - "
713
"please set TBZR to a directory to enable\n")
610
715
# MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
612
dll_excludes.append("MSWSOCK.dll")
717
dll_excludes.extend(["MSWSOCK.dll",
613
722
options_list = {"py2exe": {"packages": packages + list(additional_packages),
614
723
"includes": includes,
615
724
"excludes": excludes,
616
725
"dll_excludes": dll_excludes,
617
726
"dist_dir": "win32_bzr.exe",
728
"custom_boot_script":
729
"tools/win32/py2exe_boot_common.py",
622
setup(options=options_list,
623
console=console_targets,
625
com_server=com_targets,
626
zipfile='lib/library.zip',
627
data_files=data_files,
628
cmdclass={'install_data': install_data_with_bytecompile},
733
# We want the libaray.zip to have optimize = 2, but the exe to have
734
# optimize = 1, so that .py files that get compilied at run time
735
# (e.g. user installed plugins) dont have their doc strings removed.
736
class py2exe_no_oo_exe(py2exe.build_exe.py2exe):
737
def build_executable(self, *args, **kwargs):
739
py2exe.build_exe.py2exe.build_executable(self, *args, **kwargs)
742
if __name__ == '__main__':
743
command_classes['install_data'] = install_data_with_bytecompile
744
command_classes['py2exe'] = py2exe_no_oo_exe
745
setup(options=options_list,
746
console=console_targets,
748
zipfile='lib/library.zip',
749
data_files=data_files,
750
cmdclass=command_classes,
632
754
# ad-hoc for easy_install
634
756
if not 'bdist_egg' in sys.argv:
635
# generate and install bzr.1 only with plain install, not easy_install one
757
# generate and install bzr.1 only with plain install, not the
636
759
DATA_FILES = [('man/man1', ['bzr.1'])]
761
DATA_FILES = DATA_FILES + I18N_FILES
639
763
ARGS = {'scripts': ['bzr'],
640
764
'data_files': DATA_FILES,