/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python3
 
1
#! /usr/bin/env python
2
2
 
3
3
"""Installation script for brz.
4
4
Run it with
16
16
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.7+\n")
17
17
    sys.exit(1)
18
18
 
19
 
 
20
 
try:
21
 
    import setuptools
22
 
except ImportError:
23
 
    sys.stderr.write("[ERROR] Please install setuptools\n")
24
 
    sys.exit(1)
25
 
 
26
 
 
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:
36
28
        return f.read()
37
29
 
38
30
 
40
32
# META INFORMATION FOR SETUP
41
33
# see http://docs.python.org/dist/meta-data.html
42
34
META_INFO = {
43
 
    'name': 'breezy',
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',
 
35
    'name':         'breezy',
 
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(),
52
44
    'classifiers': [
63
55
        'Topic :: Software Development :: Version Control',
64
56
        ],
65
57
    'install_requires': [
66
 
        'configobj',
67
58
        'six>=1.9.0',
68
 
        'patiencediff',
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.
71
 
        'fastimport>=0.9.8',
72
 
        'dulwich>=0.19.12',
73
59
        ],
74
60
    'extras_require': {
75
 
        'fastimport': [],
76
 
        'git': [],
77
 
        'launchpad': ['launchpadlib>=1.6.3'],
 
61
        'fastimport': ['fastimport'],
 
62
        'git': ['dulwich>=0.19.1'],
78
63
        },
79
 
    'tests_require': [
80
 
        'testtools',
81
 
    ],
82
64
}
83
65
 
84
66
# The list of packages is automatically generated later. Add other things
85
67
# that are part of BREEZY here.
86
68
BREEZY = {}
87
69
 
88
 
PKG_DATA = {
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',
97
 
                                ]},
98
 
    }
 
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',
 
78
                                       ]},
 
79
           }
99
80
I18N_FILES = []
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'
119
100
            else:
120
 
                package_name = (
121
 
                    '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)
125
105
 
127
107
BREEZY['packages'] = get_breezy_packages()
128
108
 
129
109
 
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,
151
132
                                                             "brz"))
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 + '"'
165
147
        else:
166
148
            return path
 
149
 
 
150
    def _win_batch_args(self):
 
151
        from breezy.win32utils import winver
 
152
        if winver == 'Windows NT':
 
153
            return '%*'
 
154
        else:
 
155
            return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
167
156
#/class my_install_scripts
168
157
 
169
158
 
173
162
    """
174
163
 
175
164
    sub_commands = build.sub_commands + [
176
 
        ('build_mo', lambda _: True),
177
 
        ]
 
165
            ('build_mo', lambda _: True),
 
166
            ]
178
167
 
179
168
    def run(self):
180
169
        build.run(self)
211
200
    print("")
212
201
    from distutils.command.build_ext import build_ext
213
202
else:
214
 
    minimum_cython_version = '0.29'
 
203
    have_cython = True
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.")
222
 
        have_cython = False
223
 
    else:
224
 
        have_cython = True
225
205
 
226
206
 
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']
305
 
    ext_modules.append(
306
 
        Extension(
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))
309
288
 
310
289
 
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')
326
305
else:
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')
331
312
 
332
313
 
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))]
386
367
 
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,
396
377
    )
397
378
    console_targets.append(tbzrcache)
398
379
 
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)
403
384
 
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,
409
390
    )
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)
414
 
 
 
395
    
415
396
    # A utility to see python output from both C++ and Python based shell
416
397
    # extensions
417
398
    tracer = dict(script=os.path.join(tbzr_root, "scripts", "tbzrtrace.py"))
495
476
        for root, dirs, files in os.walk('doc'):
496
477
            r = []
497
478
            for f in files:
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))
501
482
            if r:
502
483
                relative = root[4:]
514
495
            'data_files': find_docs(),
515
496
            # for building cython extensions
516
497
            'cmdclass': command_classes,
517
 
            }
 
498
           }
518
499
 
519
500
    ARGS.update(META_INFO)
520
501
    ARGS.update(BREEZY)
569
550
            self.outfiles.extend([f + 'o' for f in compile_names])
570
551
    # end of class install_data_with_bytecompile
571
552
 
572
 
    target = py2exe.build_exe.Target(
573
 
        script="brz",
574
 
        dest_base="brz",
575
 
        icon_resources=[(0, 'brz.ico')],
576
 
        name=META_INFO['name'],
577
 
        version=version_str,
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'],
583
 
    )
 
553
    target = py2exe.build_exe.Target(script = "brz",
 
554
                                     dest_base = "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'],
 
563
                                    )
584
564
    gui_target = copy.copy(target)
585
565
    gui_target.dest_base = "bzrw"
586
566
 
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")
713
693
 
714
694
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
715
695
    # in on Vista.
725
705
                               "dist_dir": "win32_bzr.exe",
726
706
                               "optimize": 2,
727
707
                               "custom_boot_script":
728
 
                                   "tools/win32/py2exe_boot_common.py",
729
 
                               },
730
 
                    }
 
708
                                        "tools/win32/py2exe_boot_common.py",
 
709
                              },
 
710
                   }
731
711
 
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
752
732
else:
753
733
    # ad-hoc for easy_install
754
734
    DATA_FILES = []
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'])]
759
739
 
760
740
    DATA_FILES = DATA_FILES + I18N_FILES
761
741
    # std setup
762
 
    ARGS = {'scripts': ['brz',
763
 
                        # TODO(jelmer): Only install the git scripts if
764
 
                        # Dulwich was found.
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,
771
 
            }
 
746
           }
772
747
 
773
748
    ARGS.update(META_INFO)
774
749
    ARGS.update(BREEZY)