13
if sys.version_info < (2, 4):
14
sys.stderr.write("[ERROR] Not a supported Python version. Need 2.4+\n")
15
if sys.version_info < (2, 6):
16
sys.stderr.write("[ERROR] Not a supported Python version. Need 2.6+\n")
17
19
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
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',
68
71
'tests/ssl_certs/server_without_pass.key',
69
72
'tests/ssl_certs/server_with_pass.key',
70
'tests/ssl_certs/server.crt'
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]))
75
82
def get_bzrlib_packages():
76
83
"""Recurse through the bzrlib directory, and extract the package names"""
125
132
f = file(batch_path, "w")
126
133
f.write(batch_str)
128
print "Created:", batch_path
130
print "ERROR: Unable to create %s: %s" % (batch_path, e)
135
print("Created: %s" % batch_path)
137
e = sys.exc_info()[1]
138
print("ERROR: Unable to create %s: %s" % (batch_path, e))
132
140
def _quoted_path(self, path):
161
173
########################
175
from bzrlib.bzr_distutils import build_mo
163
177
command_classes = {'install_scripts': my_install_scripts,
179
'build_mo': build_mo,
165
181
from distutils import log
166
182
from distutils.errors import CCompilerError, DistutilsPlatformError
167
183
from distutils.extension import Extension
187
from Cython.Distutils import build_ext
188
from Cython.Compiler.Version import version as pyrex_version
190
print("No Cython, trying Pyrex...")
171
191
from Pyrex.Distutils import build_ext
172
192
from Pyrex.Compiler.Version import version as pyrex_version
174
print "No Pyrex, trying Cython..."
175
from Cython.Distutils import build_ext
176
from Cython.Compiler.Version import version as pyrex_version
177
193
except ImportError:
178
194
have_pyrex = False
179
195
# try to build the extension from the prior generated source.
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.")
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.")
186
202
from distutils.command.build_ext import build_ext
188
204
have_pyrex = True
189
pyrex_version_info = tuple(map(int, pyrex_version.split('.')))
205
pyrex_version_info = tuple(map(int, pyrex_version.rstrip("+").split('.')))
192
208
class build_ext_if_possible(build_ext):
206
222
build_ext.run(self)
207
except DistutilsPlatformError, e:
223
except DistutilsPlatformError:
224
e = sys.exc_info()[1]
208
225
if not self.allow_python_fallback:
209
226
log.warn('\n Cannot build extensions.\n'
210
227
' Use "build_ext --allow-python-fallback" to use'
287
304
# The code it generates re-uses a "local" pointer and
288
305
# calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
289
306
# which is NULL safe with PY_DECREF which is not.)
290
# <https://bugs.edge.launchpad.net/bzr/+bug/449372>
291
# <https://bugs.edge.launchpad.net/bzr/+bug/276868>
292
print 'Cannot build extension "bzrlib._dirstate_helpers_pyx" using'
293
print 'your version of pyrex "%s". Please upgrade your pyrex' % (
295
print 'install. For now, the non-compiled (python) version will'
296
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.')
298
315
add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
299
316
add_pyrex_extension('bzrlib._readdir_pyx')
301
318
ext_modules.append(Extension('bzrlib._patiencediff_c',
302
319
['bzrlib/_patiencediff_c.c']))
303
320
if have_pyrex and pyrex_version_info < (0, 9, 6, 3):
305
print 'Your Pyrex/Cython version %s is too old to build the simple_set' % (
307
print 'and static_tuple extensions.'
308
print 'Please upgrade to at least Pyrex 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')
310
327
# TODO: Should this be a fatal error?
312
329
# We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
320
337
if unavailable_files:
321
print 'C extension(s) not found:'
322
print ' %s' % ('\n '.join(unavailable_files),)
323
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.')
327
344
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
391
408
# ditto for the tbzrcommand tool
392
409
tbzrcommand = dict(
393
410
script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
394
icon_resources = [(0,'bzr.ico')],
411
icon_resources = icon_resources,
412
other_resources = other_resources,
396
414
console_targets.append(tbzrcommand)
397
415
tbzrcommandw = tbzrcommand.copy()
412
430
def get_qbzr_py2exe_info(includes, excludes, packages, data_files):
413
431
# PyQt4 itself still escapes the plugin detection code for some reason...
414
packages.append('PyQt4')
415
excludes.append('PyQt4.elementtree.ElementTree')
416
excludes.append('PyQt4.uic.port_v3')
432
includes.append('PyQt4.QtCore')
433
includes.append('PyQt4.QtGui')
434
includes.append('PyQt4.QtTest')
417
435
includes.append('sip') # extension module required for Qt.
418
436
packages.append('pygments') # colorizer for qbzr
419
437
packages.append('docutils') # html formatting
420
438
includes.append('win32event') # for qsubprocess stuff
421
# but we can avoid many Qt4 Dlls.
423
"""QtAssistantClient4.dll QtCLucene4.dll QtDesigner4.dll
424
QtHelp4.dll QtNetwork4.dll QtOpenGL4.dll QtScript4.dll
425
QtSql4.dll QtTest4.dll QtWebKit4.dll QtXml4.dll
426
qscintilla2.dll""".split())
427
439
# the qt binaries might not be on PATH...
428
440
# They seem to install to a place like C:\Python25\PyQt4\*
429
441
# Which is not the same as C:\Python25\Lib\site-packages\PyQt4
471
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')
474
496
if 'bdist_wininst' in sys.argv:
496
518
'data_files': find_docs(),
497
519
# for building pyrex extensions
498
'cmdclass': {'build_ext': build_ext_if_possible},
520
'cmdclass': command_classes,
501
523
ARGS.update(META_INFO)
502
524
ARGS.update(BZRLIB)
525
PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
503
526
ARGS.update(PKG_DATA)
507
530
elif 'py2exe' in sys.argv:
536
558
# time before living with docstring stripping
538
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))
539
569
byte_compile(compile_names,
540
570
optimize=optimize,
541
571
force=self.force, prefix=self.install_dir,
554
584
company_name = "Canonical Ltd.",
555
585
comments = META_INFO['description'],
587
gui_target = copy.copy(target)
588
gui_target.dest_base = "bzrw"
558
590
packages = BZRLIB['packages']
559
591
packages.remove('bzrlib')
644
676
console_targets = [target,
645
677
'tools/win32/bzr_postinstall.py',
648
data_files = topics_files + plugins_files
679
gui_targets = [gui_target]
680
data_files = topics_files + plugins_files + I18N_FILES
650
682
if 'qbzr' in plugins:
651
683
get_qbzr_py2exe_info(includes, excludes, packages, data_files)
653
685
if 'svn' in plugins:
654
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)
656
694
if "TBZR" in os.environ:
657
695
# TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
658
696
# TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
677
715
# print this warning to stderr as output is redirected, so it is seen
678
716
# at build time. Also to stdout so it appears in the log
679
717
for f in (sys.stderr, sys.stdout):
681
"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")
683
721
# MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
685
dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
723
dll_excludes.extend(["MSWSOCK.dll",
686
728
options_list = {"py2exe": {"packages": packages + list(additional_packages),
687
729
"includes": includes,
688
730
"excludes": excludes,
689
731
"dll_excludes": dll_excludes,
690
732
"dist_dir": "win32_bzr.exe",
734
"custom_boot_script":
735
"tools/win32/py2exe_boot_common.py",
695
setup(options=options_list,
696
console=console_targets,
698
zipfile='lib/library.zip',
699
data_files=data_files,
700
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,
704
760
# ad-hoc for easy_install
708
764
# easy_install one
709
765
DATA_FILES = [('man/man1', ['bzr.1'])]
711
if sys.platform != 'win32':
712
# see https://wiki.kubuntu.org/Apport/DeveloperHowTo
714
# checking the paths and hardcoding the check for root is a bit gross,
715
# but I don't see a cleaner way to find out the locations in a way
716
# that's going to align with the hardcoded paths in apport.
717
if os.geteuid() == 0:
719
('/usr/share/apport/package-hooks',
720
['apport/source_bzr.py']),
721
('/etc/apport/crashdb.conf.d/',
722
['apport/bzr-crashdb.conf']),]
767
DATA_FILES = DATA_FILES + I18N_FILES
725
769
ARGS = {'scripts': ['bzr'],
726
770
'data_files': DATA_FILES,