16
16
sys.stderr.write("[ERROR] Not a supported Python version. Need 2.7+\n")
23
sys.stderr.write("[ERROR] Please install setuptools\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
29
21
# start of the path, so this should find the right one...
32
24
def get_long_description():
33
25
dirname = os.path.dirname(__file__)
34
26
readme = os.path.join(dirname, 'README.rst')
35
with open(readme, 'r') as f:
27
with open(readme, 'rb') as f:
40
32
# META INFORMATION FOR SETUP
41
33
# 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',
36
'version': breezy.__version__,
37
'maintainer': 'Breezy Developers',
38
'maintainer_email': 'team@breezy-vcs.org',
39
'url': 'https://www.breezy-vcs.org/',
40
'description': 'Friendly distributed version control system',
41
'license': 'GNU GPL v2',
50
42
'download_url': 'https://launchpad.net/brz/+download',
51
43
'long_description': get_long_description(),
63
55
'Topic :: Software Development :: Version Control',
65
57
'install_requires': [
69
# Technically, Breezy works without these two dependencies too. But there's
70
# no way to enable them by default and let users opt out.
74
60
'extras_require': {
77
'launchpad': ['launchpadlib>=1.6.3'],
61
'fastimport': ['fastimport'],
62
'git': ['dulwich>=0.19.1'],
84
66
# The list of packages is automatically generated later. Add other things
85
67
# that are part of BREEZY here.
89
# install files from selftest suite
90
'package_data': {'breezy': ['doc/api/*.txt',
91
'tests/test_patches_data/*',
92
'help_topics/en/*.txt',
93
'tests/ssl_certs/ca.crt',
94
'tests/ssl_certs/server_without_pass.key',
95
'tests/ssl_certs/server_with_pass.key',
96
'tests/ssl_certs/server.crt',
70
PKG_DATA = {# install files from selftest suite
71
'package_data': {'breezy': ['doc/api/*.txt',
72
'tests/test_patches_data/*',
73
'help_topics/en/*.txt',
74
'tests/ssl_certs/ca.crt',
75
'tests/ssl_certs/server_without_pass.key',
76
'tests/ssl_certs/server_with_pass.key',
77
'tests/ssl_certs/server.crt',
100
81
for filepath in glob.glob("breezy/locale/*/LC_MESSAGES/*.mo"):
101
82
langfile = filepath[len("breezy/locale/"):]
117
98
if not package_path:
118
99
package_name = 'breezy'
122
package_path.replace('/', '.').replace('\\', '.'))
101
package_name = ('breezy.' +
102
package_path.replace('/', '.').replace('\\', '.'))
123
103
packages.append(package_name)
124
104
return sorted(packages)
127
107
BREEZY['packages'] = get_breezy_packages()
130
from setuptools import setup
110
from distutils import log
111
from distutils.core import setup
131
112
from distutils.version import LooseVersion
132
113
from distutils.command.install_scripts import install_scripts
133
114
from distutils.command.install_data import install_data
150
131
script_path = self._quoted_path(os.path.join(scripts_dir,
152
133
python_exe = self._quoted_path(sys.executable)
153
batch_str = "@%s %s %%*" % (python_exe, script_path)
134
args = self._win_batch_args()
135
batch_str = "@%s %s %s" % (python_exe, script_path, args)
154
136
batch_path = os.path.join(self.install_dir, "brz.bat")
155
with open(batch_path, "w") as f:
137
with file(batch_path, "w") as f:
156
138
f.write(batch_str)
157
139
print(("Created: %s" % batch_path))
158
140
except Exception:
164
146
return '"' + path + '"'
150
def _win_batch_args(self):
151
from breezy.win32utils import winver
152
if winver == 'Windows NT':
155
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
167
156
#/class my_install_scripts
175
164
sub_commands = build.sub_commands + [
176
('build_mo', lambda _: True),
165
('build_mo', lambda _: True),
212
201
from distutils.command.build_ext import build_ext
214
minimum_cython_version = '0.29'
215
204
cython_version_info = LooseVersion(cython_version)
216
if cython_version_info < LooseVersion(minimum_cython_version):
217
print("Version of Cython is too old. "
218
"Current is %s, need at least %s."
219
% (cython_version, minimum_cython_version))
220
print("If the .c files are available, they will be built,"
221
" but modifying the .pyx files will not rebuild them.")
227
207
class build_ext_if_possible(build_ext):
302
282
source = [c_name]
303
283
source.extend(extra_source)
304
284
include_dirs = ['breezy']
307
module_name, source, define_macros=define_macros,
308
libraries=libraries, include_dirs=include_dirs))
285
ext_modules.append(Extension(module_name, source,
286
define_macros=define_macros, libraries=libraries,
287
include_dirs=include_dirs))
311
290
add_cython_extension('breezy._simple_set_pyx')
315
294
add_cython_extension('breezy._bencode_pyx')
316
295
add_cython_extension('breezy._chunks_to_lines_pyx')
317
296
add_cython_extension('breezy.bzr._groupcompress_pyx',
318
extra_source=['breezy/bzr/diff-delta.c'])
297
extra_source=['breezy/bzr/diff-delta.c'])
319
298
add_cython_extension('breezy.bzr._knit_load_data_pyx')
320
299
add_cython_extension('breezy._known_graph_pyx')
321
300
add_cython_extension('breezy._rio_pyx')
322
301
if sys.platform == 'win32':
323
302
add_cython_extension('breezy.bzr._dirstate_helpers_pyx',
324
libraries=['Ws2_32'])
303
libraries=['Ws2_32'])
325
304
add_cython_extension('breezy._walkdirs_win32')
327
306
add_cython_extension('breezy.bzr._dirstate_helpers_pyx')
328
307
add_cython_extension('breezy._readdir_pyx')
329
308
add_cython_extension('breezy.bzr._chk_map_pyx')
309
ext_modules.append(Extension('breezy._patiencediff_c',
310
['breezy/_patiencediff_c.c']))
330
311
add_cython_extension('breezy.bzr._btree_serializer_pyx')
369
350
# First always brz's icon and its in the root of the brz tree.
370
351
icos.append(('', 'brz.ico'))
371
352
for root, dirs, files in os.walk(ico_root):
372
icos.extend([(ico_root, os.path.join(root, f)[len(ico_root) + 1:])
353
icos.extend([(ico_root, os.path.join(root, f)[len(ico_root)+1:])
373
354
for f in files if f.endswith('.ico')])
374
355
# allocate an icon ID for each file and the full path to the ico
375
356
icon_resources = [(rid, os.path.join(ico_dir, ico_name))
382
363
for rid, (_, f) in enumerate(icos)]
383
364
ico_map = dict(map_items)
384
365
# Create a new resource type of 'ICON_MAP', and use ID=1
385
other_resources = [("ICON_MAP", 1, pickle.dumps(ico_map))]
366
other_resources = [ ("ICON_MAP", 1, pickle.dumps(ico_map))]
387
368
excludes.extend("""pywin pywin.dialogs pywin.dialogs.list
388
369
win32ui crawler.Crawler""".split())
390
371
# tbzrcache executables - a "console" version for debugging and a
391
372
# GUI version that is generally used.
392
373
tbzrcache = dict(
393
script=os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
394
icon_resources=icon_resources,
395
other_resources=other_resources,
374
script = os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
375
icon_resources = icon_resources,
376
other_resources = other_resources,
397
378
console_targets.append(tbzrcache)
399
380
# Make a windows version which is the same except for the base name.
400
381
tbzrcachew = tbzrcache.copy()
401
tbzrcachew["dest_base"] = "tbzrcachew"
382
tbzrcachew["dest_base"]="tbzrcachew"
402
383
gui_targets.append(tbzrcachew)
404
385
# ditto for the tbzrcommand tool
405
386
tbzrcommand = dict(
406
script=os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
407
icon_resources=icon_resources,
408
other_resources=other_resources,
387
script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
388
icon_resources = icon_resources,
389
other_resources = other_resources,
410
391
console_targets.append(tbzrcommand)
411
392
tbzrcommandw = tbzrcommand.copy()
412
tbzrcommandw["dest_base"] = "tbzrcommandw"
393
tbzrcommandw["dest_base"]="tbzrcommandw"
413
394
gui_targets.append(tbzrcommandw)
415
396
# A utility to see python output from both C++ and Python based shell
417
398
tracer = dict(script=os.path.join(tbzr_root, "scripts", "tbzrtrace.py"))
495
476
for root, dirs, files in os.walk('doc'):
498
if (os.path.splitext(f)[1] in ('.html', '.css', '.png', '.pdf')
499
or f == 'quick-start-summary.svg'):
479
if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
480
or f == 'quick-start-summary.svg'):
500
481
r.append(os.path.join(root, f))
502
483
relative = root[4:]
569
550
self.outfiles.extend([f + 'o' for f in compile_names])
570
551
# end of class install_data_with_bytecompile
572
target = py2exe.build_exe.Target(
575
icon_resources=[(0, 'brz.ico')],
576
name=META_INFO['name'],
578
description=META_INFO['description'],
579
author=META_INFO['author'],
580
copyright="(c) Canonical Ltd, 2005-2010",
581
company_name="Canonical Ltd.",
582
comments=META_INFO['description'],
553
target = py2exe.build_exe.Target(script = "brz",
555
icon_resources = [(0,'brz.ico')],
556
name = META_INFO['name'],
557
version = version_str,
558
description = META_INFO['description'],
559
author = META_INFO['author'],
560
copyright = "(c) Canonical Ltd, 2005-2010",
561
company_name = "Canonical Ltd.",
562
comments = META_INFO['description'],
584
564
gui_target = copy.copy(target)
585
565
gui_target.dest_base = "bzrw"
709
689
# at build time. Also to stdout so it appears in the log
710
690
for f in (sys.stderr, sys.stdout):
711
691
f.write("Skipping TBZR binaries - "
712
"please set TBZR to a directory to enable\n")
692
"please set TBZR to a directory to enable\n")
714
694
# MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
725
705
"dist_dir": "win32_bzr.exe",
727
707
"custom_boot_script":
728
"tools/win32/py2exe_boot_common.py",
708
"tools/win32/py2exe_boot_common.py",
732
712
# We want the libaray.zip to have optimize = 2, but the exe to have
733
713
# optimize = 1, so that .py files that get compilied at run time
753
733
# ad-hoc for easy_install
755
if 'bdist_egg' not in sys.argv:
735
if not 'bdist_egg' in sys.argv:
756
736
# generate and install brz.1 only with plain install, not the
757
737
# easy_install one
758
DATA_FILES = [('man/man1', ['brz.1', 'breezy/git/git-remote-bzr.1'])]
738
DATA_FILES = [('man/man1', ['brz.1'])]
760
740
DATA_FILES = DATA_FILES + I18N_FILES
762
ARGS = {'scripts': ['brz',
763
# TODO(jelmer): Only install the git scripts if
765
'breezy/git/git-remote-bzr',
766
'breezy/git/bzr-receive-pack',
767
'breezy/git/bzr-upload-pack'],
742
ARGS = {'scripts': ['brz'],
768
743
'data_files': DATA_FILES,
769
744
'cmdclass': command_classes,
770
745
'ext_modules': ext_modules,
773
748
ARGS.update(META_INFO)
774
749
ARGS.update(BREEZY)