15
if sys.version_info < (3, 5):
16
sys.stderr.write("[ERROR] Not a supported Python version. Need 3.5+\n")
22
except ImportError as e:
23
sys.stderr.write("[ERROR] Please install setuptools (%s)\n" % e)
15
if sys.version_info < (2, 7):
16
sys.stderr.write("[ERROR] Not a supported Python version. Need 2.7+\n")
27
19
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
28
20
# './setup.py' or the equivalent with another path, should always be at the
32
24
def get_long_description():
33
25
dirname = os.path.dirname(__file__)
34
readme = os.path.join(dirname, 'README.rst')
35
with open(readme, 'r') as f:
26
readme = os.path.join(dirname, 'README')
27
f = open(readme, 'rb')
40
35
# META INFORMATION FOR SETUP
41
36
# see http://docs.python.org/dist/meta-data.html
44
'version': breezy.__version__,
45
'maintainer': 'Breezy Developers',
46
'maintainer_email': 'team@breezy-vcs.org',
47
'url': 'https://www.breezy-vcs.org/',
48
'description': 'Friendly distributed version control system',
49
'license': 'GNU GPL v2',
39
'version': breezy.__version__,
40
'author': 'Canonical Ltd',
41
'author_email': 'bazaar@lists.canonical.com',
42
'maintainer': 'Breezy Developers',
43
'url': 'https://www.breezy-vcs.org/',
44
'description': 'Friendly distributed version control system',
45
'license': 'GNU GPL v2',
50
46
'download_url': 'https://launchpad.net/brz/+download',
51
47
'long_description': get_long_description(),
62
58
'Programming Language :: C',
63
59
'Topic :: Software Development :: Version Control',
68
# Technically, Breezy works without these two dependencies too. But there's
69
# no way to enable them by default and let users opt out.
70
'dulwich>=0.19.12;python_version>="3.5"',
71
'dulwich<0.20,>=0.19.12;python_version<"3.0"',
76
'launchpad': ['launchpadlib>=1.6.3'],
77
'workspace': ['pyinotify'],
81
'testtools<=2.4.0;python_version<"3.0"',
86
63
# The list of packages is automatically generated later. Add other things
87
# that are part of BREEZY here.
64
# that are part of BZRLIB here.
91
# install files from selftest suite
92
'package_data': {'breezy': ['doc/api/*.txt',
93
'tests/test_patches_data/*',
94
'help_topics/en/*.txt',
95
'tests/ssl_certs/ca.crt',
96
'tests/ssl_certs/server_without_pass.key',
97
'tests/ssl_certs/server_with_pass.key',
98
'tests/ssl_certs/server.crt',
67
PKG_DATA = {# install files from selftest suite
68
'package_data': {'breezy': ['doc/api/*.txt',
69
'tests/test_patches_data/*',
70
'help_topics/en/*.txt',
71
'tests/ssl_certs/ca.crt',
72
'tests/ssl_certs/server_without_pass.key',
73
'tests/ssl_certs/server_with_pass.key',
74
'tests/ssl_certs/server.crt',
102
78
for filepath in glob.glob("breezy/locale/*/LC_MESSAGES/*.mo"):
103
79
langfile = filepath[len("breezy/locale/"):]
119
95
if not package_path:
120
96
package_name = 'breezy'
124
package_path.replace('/', '.').replace('\\', '.'))
98
package_name = ('breezy.' +
99
package_path.replace('/', '.').replace('\\', '.'))
125
100
packages.append(package_name)
126
101
return sorted(packages)
129
BREEZY['packages'] = get_breezy_packages()
132
from setuptools import setup
104
BZRLIB['packages'] = get_breezy_packages()
107
from distutils import log
108
from distutils.core import setup
133
109
from distutils.version import LooseVersion
134
110
from distutils.command.install_scripts import install_scripts
135
111
from distutils.command.install_data import install_data
152
128
script_path = self._quoted_path(os.path.join(scripts_dir,
154
130
python_exe = self._quoted_path(sys.executable)
155
batch_str = "@%s %s %%*" % (python_exe, script_path)
131
args = self._win_batch_args()
132
batch_str = "@%s %s %s" % (python_exe, script_path, args)
156
133
batch_path = os.path.join(self.install_dir, "brz.bat")
157
with open(batch_path, "w") as f:
134
f = file(batch_path, "w")
159
137
print(("Created: %s" % batch_path))
160
138
except Exception:
161
139
e = sys.exc_info()[1]
166
144
return '"' + path + '"'
148
def _win_batch_args(self):
149
from breezy.win32utils import winver
150
if winver == 'Windows NT':
153
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
169
154
#/class my_install_scripts
177
162
sub_commands = build.sub_commands + [
178
('build_mo', lambda _: True),
163
('build_mo', lambda _: True),
214
199
from distutils.command.build_ext import build_ext
216
minimum_cython_version = '0.29'
217
202
cython_version_info = LooseVersion(cython_version)
218
if cython_version_info < LooseVersion(minimum_cython_version):
219
print("Version of Cython is too old. "
220
"Current is %s, need at least %s."
221
% (cython_version, minimum_cython_version))
222
print("If the .c files are available, they will be built,"
223
" but modifying the .pyx files will not rebuild them.")
229
205
class build_ext_if_possible(build_ext):
304
280
source = [c_name]
305
281
source.extend(extra_source)
306
282
include_dirs = ['breezy']
309
module_name, source, define_macros=define_macros,
310
libraries=libraries, include_dirs=include_dirs))
283
ext_modules.append(Extension(module_name, source,
284
define_macros=define_macros, libraries=libraries,
285
include_dirs=include_dirs))
313
288
add_cython_extension('breezy._simple_set_pyx')
317
292
add_cython_extension('breezy._bencode_pyx')
318
293
add_cython_extension('breezy._chunks_to_lines_pyx')
319
294
add_cython_extension('breezy.bzr._groupcompress_pyx',
320
extra_source=['breezy/bzr/diff-delta.c'])
295
extra_source=['breezy/bzr/diff-delta.c'])
321
296
add_cython_extension('breezy.bzr._knit_load_data_pyx')
322
297
add_cython_extension('breezy._known_graph_pyx')
323
298
add_cython_extension('breezy._rio_pyx')
324
299
if sys.platform == 'win32':
325
300
add_cython_extension('breezy.bzr._dirstate_helpers_pyx',
326
libraries=['Ws2_32'])
301
libraries=['Ws2_32'])
327
302
add_cython_extension('breezy._walkdirs_win32')
329
304
add_cython_extension('breezy.bzr._dirstate_helpers_pyx')
330
305
add_cython_extension('breezy._readdir_pyx')
331
306
add_cython_extension('breezy.bzr._chk_map_pyx')
307
ext_modules.append(Extension('breezy._patiencediff_c',
308
['breezy/_patiencediff_c.c']))
332
309
add_cython_extension('breezy.bzr._btree_serializer_pyx')
371
348
# First always brz's icon and its in the root of the brz tree.
372
349
icos.append(('', 'brz.ico'))
373
350
for root, dirs, files in os.walk(ico_root):
374
icos.extend([(ico_root, os.path.join(root, f)[len(ico_root) + 1:])
351
icos.extend([(ico_root, os.path.join(root, f)[len(ico_root)+1:])
375
352
for f in files if f.endswith('.ico')])
376
353
# allocate an icon ID for each file and the full path to the ico
377
354
icon_resources = [(rid, os.path.join(ico_dir, ico_name))
384
361
for rid, (_, f) in enumerate(icos)]
385
362
ico_map = dict(map_items)
386
363
# Create a new resource type of 'ICON_MAP', and use ID=1
387
other_resources = [("ICON_MAP", 1, pickle.dumps(ico_map))]
364
other_resources = [ ("ICON_MAP", 1, pickle.dumps(ico_map))]
389
366
excludes.extend("""pywin pywin.dialogs pywin.dialogs.list
390
367
win32ui crawler.Crawler""".split())
392
369
# tbzrcache executables - a "console" version for debugging and a
393
370
# GUI version that is generally used.
394
371
tbzrcache = dict(
395
script=os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
396
icon_resources=icon_resources,
397
other_resources=other_resources,
372
script = os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
373
icon_resources = icon_resources,
374
other_resources = other_resources,
399
376
console_targets.append(tbzrcache)
401
378
# Make a windows version which is the same except for the base name.
402
379
tbzrcachew = tbzrcache.copy()
403
tbzrcachew["dest_base"] = "tbzrcachew"
380
tbzrcachew["dest_base"]="tbzrcachew"
404
381
gui_targets.append(tbzrcachew)
406
383
# ditto for the tbzrcommand tool
407
384
tbzrcommand = dict(
408
script=os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
409
icon_resources=icon_resources,
410
other_resources=other_resources,
385
script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
386
icon_resources = icon_resources,
387
other_resources = other_resources,
412
389
console_targets.append(tbzrcommand)
413
390
tbzrcommandw = tbzrcommand.copy()
414
tbzrcommandw["dest_base"] = "tbzrcommandw"
391
tbzrcommandw["dest_base"]="tbzrcommandw"
415
392
gui_targets.append(tbzrcommandw)
417
394
# A utility to see python output from both C++ and Python based shell
419
396
tracer = dict(script=os.path.join(tbzr_root, "scripts", "tbzrtrace.py"))
497
474
for root, dirs, files in os.walk('doc'):
500
if (os.path.splitext(f)[1] in ('.html', '.css', '.png', '.pdf')
501
or f == 'quick-start-summary.svg'):
477
if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
478
or f == 'quick-start-summary.svg'):
502
479
r.append(os.path.join(root, f))
504
481
relative = root[4:]
516
493
'data_files': find_docs(),
517
494
# for building cython extensions
518
495
'cmdclass': command_classes,
521
498
ARGS.update(META_INFO)
523
500
PKG_DATA['package_data']['breezy'].append('locale/*/LC_MESSAGES/*.mo')
524
501
ARGS.update(PKG_DATA)
571
548
self.outfiles.extend([f + 'o' for f in compile_names])
572
549
# end of class install_data_with_bytecompile
574
target = py2exe.build_exe.Target(
577
icon_resources=[(0, 'brz.ico')],
578
name=META_INFO['name'],
580
description=META_INFO['description'],
581
author=META_INFO['author'],
582
copyright="(c) Canonical Ltd, 2005-2010",
583
company_name="Canonical Ltd.",
584
comments=META_INFO['description'],
551
target = py2exe.build_exe.Target(script = "brz",
553
icon_resources = [(0,'brz.ico')],
554
name = META_INFO['name'],
555
version = version_str,
556
description = META_INFO['description'],
557
author = META_INFO['author'],
558
copyright = "(c) Canonical Ltd, 2005-2010",
559
company_name = "Canonical Ltd.",
560
comments = META_INFO['description'],
586
562
gui_target = copy.copy(target)
587
563
gui_target.dest_base = "bzrw"
589
packages = BREEZY['packages']
565
packages = BZRLIB['packages']
590
566
packages.remove('breezy')
591
567
packages = [i for i in packages if not i.startswith('breezy.plugins')]
597
573
includes.append(module)
599
575
additional_packages = set()
576
if sys.version.startswith('2.7'):
577
additional_packages.add('xml.etree')
580
warnings.warn('Unknown Python version.\n'
581
'Please check setup.py script for compatibility.')
601
583
# Although we currently can't enforce it, we consider it an error for
602
584
# py2exe to report any files are "missing". Such modules we know aren't
705
687
# at build time. Also to stdout so it appears in the log
706
688
for f in (sys.stderr, sys.stdout):
707
689
f.write("Skipping TBZR binaries - "
708
"please set TBZR to a directory to enable\n")
690
"please set TBZR to a directory to enable\n")
710
692
# MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
721
703
"dist_dir": "win32_bzr.exe",
723
705
"custom_boot_script":
724
"tools/win32/py2exe_boot_common.py",
706
"tools/win32/py2exe_boot_common.py",
728
710
# We want the libaray.zip to have optimize = 2, but the exe to have
729
711
# optimize = 1, so that .py files that get compilied at run time
749
731
# ad-hoc for easy_install
751
if 'bdist_egg' not in sys.argv:
733
if not 'bdist_egg' in sys.argv:
752
734
# generate and install brz.1 only with plain install, not the
753
735
# easy_install one
754
DATA_FILES = [('man/man1', ['brz.1', 'breezy/git/git-remote-bzr.1'])]
736
DATA_FILES = [('man/man1', ['brz.1'])]
756
738
DATA_FILES = DATA_FILES + I18N_FILES
758
ARGS = {'scripts': ['brz',
759
# TODO(jelmer): Only install the git scripts if
761
'breezy/git/git-remote-bzr',
762
'breezy/git/bzr-receive-pack',
763
'breezy/git/bzr-upload-pack'],
740
ARGS = {'scripts': ['brz'],
764
741
'data_files': DATA_FILES,
765
742
'cmdclass': command_classes,
766
743
'ext_modules': ext_modules,
769
746
ARGS.update(META_INFO)
771
748
ARGS.update(PKG_DATA)
773
750
if __name__ == '__main__':