/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
"""Installation script for bzr.
 
3
"""Installation script for brz.
4
4
Run it with
5
5
 './setup.py install', or
6
6
 './setup.py --help' for more options
12
12
import copy
13
13
import glob
14
14
 
15
 
if sys.version_info < (2, 6):
16
 
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.6+\n")
 
15
if sys.version_info < (2, 7):
 
16
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.7+\n")
17
17
    sys.exit(1)
18
18
 
19
19
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
20
20
# './setup.py' or the equivalent with another path, should always be at the
21
21
# start of the path, so this should find the right one...
22
 
import bzrlib
 
22
import breezy
23
23
 
24
24
def get_long_description():
25
25
    dirname = os.path.dirname(__file__)
35
35
# META INFORMATION FOR SETUP
36
36
# see http://docs.python.org/dist/meta-data.html
37
37
META_INFO = {
38
 
    'name':         'bzr',
39
 
    'version':      bzrlib.__version__,
 
38
    'name':         'brz',
 
39
    'version':      breezy.__version__,
40
40
    'author':       'Canonical Ltd',
41
41
    'author_email': 'bazaar@lists.canonical.com',
 
42
    'maintainer':   'Breezy Developers',
42
43
    'url':          'http://bazaar.canonical.com/',
43
44
    'description':  'Friendly distributed version control system',
44
45
    'license':      'GNU GPL v2',
64
65
BZRLIB = {}
65
66
 
66
67
PKG_DATA = {# install files from selftest suite
67
 
            'package_data': {'bzrlib': ['doc/api/*.txt',
 
68
            'package_data': {'breezy': ['doc/api/*.txt',
68
69
                                        'tests/test_patches_data/*',
69
70
                                        'help_topics/en/*.txt',
70
71
                                        'tests/ssl_certs/ca.crt',
74
75
                                       ]},
75
76
           }
76
77
I18N_FILES = []
77
 
for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
78
 
    langfile = filepath[len("bzrlib/locale/"):]
 
78
for filepath in glob.glob("breezy/locale/*/LC_MESSAGES/*.mo"):
 
79
    langfile = filepath[len("breezy/locale/"):]
79
80
    targetpath = os.path.dirname(os.path.join("share/locale", langfile))
80
81
    I18N_FILES.append((targetpath, [filepath]))
81
82
 
82
 
def get_bzrlib_packages():
83
 
    """Recurse through the bzrlib directory, and extract the package names"""
 
83
def get_breezy_packages():
 
84
    """Recurse through the breezy directory, and extract the package names"""
84
85
 
85
86
    packages = []
86
 
    base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
 
87
    base_path = os.path.dirname(os.path.abspath(breezy.__file__))
87
88
    for root, dirs, files in os.walk(base_path):
88
89
        if '__init__.py' in files:
89
90
            assert root.startswith(base_path)
90
 
            # Get just the path below bzrlib
 
91
            # Get just the path below breezy
91
92
            package_path = root[len(base_path):]
92
93
            # Remove leading and trailing slashes
93
94
            package_path = package_path.strip('\\/')
94
95
            if not package_path:
95
 
                package_name = 'bzrlib'
 
96
                package_name = 'breezy'
96
97
            else:
97
 
                package_name = ('bzrlib.' +
 
98
                package_name = ('breezy.' +
98
99
                            package_path.replace('/', '.').replace('\\', '.'))
99
100
            packages.append(package_name)
100
101
    return sorted(packages)
101
102
 
102
103
 
103
 
BZRLIB['packages'] = get_bzrlib_packages()
 
104
BZRLIB['packages'] = get_breezy_packages()
104
105
 
105
106
 
106
107
from distutils import log
116
117
 
117
118
class my_install_scripts(install_scripts):
118
119
    """ Customized install_scripts distutils action.
119
 
    Create bzr.bat for win32.
 
120
    Create brz.bat for win32.
120
121
    """
121
122
    def run(self):
122
123
        install_scripts.run(self)   # standard action
125
126
            try:
126
127
                scripts_dir = os.path.join(sys.prefix, 'Scripts')
127
128
                script_path = self._quoted_path(os.path.join(scripts_dir,
128
 
                                                             "bzr"))
 
129
                                                             "brz"))
129
130
                python_exe = self._quoted_path(sys.executable)
130
131
                args = self._win_batch_args()
131
132
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
132
 
                batch_path = os.path.join(self.install_dir, "bzr.bat")
 
133
                batch_path = os.path.join(self.install_dir, "brz.bat")
133
134
                f = file(batch_path, "w")
134
135
                f.write(batch_str)
135
136
                f.close()
136
 
                print("Created: %s" % batch_path)
 
137
                print(("Created: %s" % batch_path))
137
138
            except Exception:
138
139
                e = sys.exc_info()[1]
139
 
                print("ERROR: Unable to create %s: %s" % (batch_path, e))
 
140
                print(("ERROR: Unable to create %s: %s" % (batch_path, e)))
140
141
 
141
142
    def _quoted_path(self, path):
142
143
        if ' ' in path:
145
146
            return path
146
147
 
147
148
    def _win_batch_args(self):
148
 
        from bzrlib.win32utils import winver
 
149
        from breezy.win32utils import winver
149
150
        if winver == 'Windows NT':
150
151
            return '%*'
151
152
        else:
155
156
 
156
157
class bzr_build(build):
157
158
    """Customized build distutils action.
158
 
    Generate bzr.1.
 
159
    Generate brz.1.
159
160
    """
160
161
 
161
162
    sub_commands = build.sub_commands + [
166
167
        build.run(self)
167
168
 
168
169
        from tools import generate_docs
169
 
        generate_docs.main(argv=["bzr", "man"])
 
170
        generate_docs.main(argv=["brz", "man"])
170
171
 
171
172
 
172
173
########################
173
174
## Setup
174
175
########################
175
176
 
176
 
from bzrlib.bzr_distutils import build_mo
 
177
from breezy.bzr_distutils import build_mo
177
178
 
178
179
command_classes = {'install_scripts': my_install_scripts,
179
180
                   'build': bzr_build,
287
288
        define_macros=define_macros, libraries=libraries))
288
289
 
289
290
 
290
 
add_pyrex_extension('bzrlib._annotator_pyx')
291
 
add_pyrex_extension('bzrlib._bencode_pyx')
292
 
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
293
 
add_pyrex_extension('bzrlib._groupcompress_pyx',
294
 
                    extra_source=['bzrlib/diff-delta.c'])
295
 
add_pyrex_extension('bzrlib._knit_load_data_pyx')
296
 
add_pyrex_extension('bzrlib._known_graph_pyx')
297
 
add_pyrex_extension('bzrlib._rio_pyx')
 
291
add_pyrex_extension('breezy._annotator_pyx')
 
292
add_pyrex_extension('breezy._bencode_pyx')
 
293
add_pyrex_extension('breezy._chunks_to_lines_pyx')
 
294
add_pyrex_extension('breezy._groupcompress_pyx',
 
295
                    extra_source=['breezy/diff-delta.c'])
 
296
add_pyrex_extension('breezy._knit_load_data_pyx')
 
297
add_pyrex_extension('breezy._known_graph_pyx')
 
298
add_pyrex_extension('breezy._rio_pyx')
298
299
if sys.platform == 'win32':
299
 
    add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
 
300
    add_pyrex_extension('breezy._dirstate_helpers_pyx',
300
301
                        libraries=['Ws2_32'])
301
 
    add_pyrex_extension('bzrlib._walkdirs_win32')
 
302
    add_pyrex_extension('breezy._walkdirs_win32')
302
303
else:
303
304
    if have_pyrex and pyrex_version_info == LooseVersion("0.9.4.1"):
304
305
        # Pyrex 0.9.4.1 fails to compile this extension correctly
307
308
        # which is NULL safe with PY_DECREF which is not.)
308
309
        # <https://bugs.launchpad.net/bzr/+bug/449372>
309
310
        # <https://bugs.launchpad.net/bzr/+bug/276868>
310
 
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
311
 
        print('your version of pyrex "%s". Please upgrade your pyrex'
312
 
              % (pyrex_version,))
 
311
        print('Cannot build extension "breezy._dirstate_helpers_pyx" using')
 
312
        print(('your version of pyrex "%s". Please upgrade your pyrex'
 
313
              % (pyrex_version,)))
313
314
        print('install. For now, the non-compiled (python) version will')
314
315
        print('be used instead.')
315
316
    else:
316
 
        add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
317
 
    add_pyrex_extension('bzrlib._readdir_pyx')
318
 
add_pyrex_extension('bzrlib._chk_map_pyx')
319
 
ext_modules.append(Extension('bzrlib._patiencediff_c',
320
 
                             ['bzrlib/_patiencediff_c.c']))
 
317
        add_pyrex_extension('breezy._dirstate_helpers_pyx')
 
318
    add_pyrex_extension('breezy._readdir_pyx')
 
319
add_pyrex_extension('breezy._chk_map_pyx')
 
320
ext_modules.append(Extension('breezy._patiencediff_c',
 
321
                             ['breezy/_patiencediff_c.c']))
321
322
if have_pyrex and pyrex_version_info < LooseVersion("0.9.6.3"):
322
323
    print("")
323
 
    print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
324
 
        pyrex_version))
 
324
    print(('Your Pyrex/Cython version %s is too old to build the simple_set' % (
 
325
        pyrex_version)))
325
326
    print('and static_tuple extensions.')
326
327
    print('Please upgrade to at least Pyrex 0.9.6.3')
327
328
    print("")
329
330
else:
330
331
    # We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
331
332
    # on simple_set
332
 
    add_pyrex_extension('bzrlib._simple_set_pyx')
333
 
    ext_modules.append(Extension('bzrlib._static_tuple_c',
334
 
                                 ['bzrlib/_static_tuple_c.c']))
335
 
add_pyrex_extension('bzrlib._btree_serializer_pyx')
 
333
    add_pyrex_extension('breezy._simple_set_pyx')
 
334
    ext_modules.append(Extension('breezy._static_tuple_c',
 
335
                                 ['breezy/_static_tuple_c.c']))
 
336
add_pyrex_extension('breezy._btree_serializer_pyx')
336
337
 
337
338
 
338
339
if unavailable_files:
339
340
    print('C extension(s) not found:')
340
 
    print('   %s' % ('\n  '.join(unavailable_files),))
 
341
    print(('   %s' % ('\n  '.join(unavailable_files),)))
341
342
    print('The python versions will be used instead.')
342
343
    print("")
343
344
 
362
363
    # TBZR points to the TBZR directory
363
364
    tbzr_root = os.environ["TBZR"]
364
365
 
365
 
    # Ensure tbzrlib itself is on sys.path
 
366
    # Ensure tbreezy itself is on sys.path
366
367
    sys.path.append(tbzr_root)
367
368
 
368
 
    packages.append("tbzrlib")
 
369
    packages.append("tbreezy")
369
370
 
370
371
    # collect up our icons.
371
372
    cwd = os.getcwd()
372
 
    ico_root = os.path.join(tbzr_root, 'tbzrlib', 'resources')
 
373
    ico_root = os.path.join(tbzr_root, 'tbreezy', 'resources')
373
374
    icos = [] # list of (path_root, relative_ico_path)
374
 
    # First always bzr's icon and its in the root of the bzr tree.
375
 
    icos.append(('', 'bzr.ico'))
 
375
    # First always brz's icon and its in the root of the brz tree.
 
376
    icos.append(('', 'brz.ico'))
376
377
    for root, dirs, files in os.walk(ico_root):
377
378
        icos.extend([(ico_root, os.path.join(root, f)[len(ico_root)+1:])
378
379
                     for f in files if f.endswith('.ico')])
490
491
 
491
492
def get_fastimport_py2exe_info(includes, excludes, packages):
492
493
    # This is the python-fastimport package, not to be confused with the
493
 
    # bzr-fastimport plugin.
 
494
    # brz-fastimport plugin.
494
495
    packages.append('fastimport')
495
496
 
496
497
 
506
507
            if r:
507
508
                relative = root[4:]
508
509
                if relative:
509
 
                    target = os.path.join('Doc\\Bazaar', relative)
 
510
                    target = os.path.join('Doc\\Breezy', relative)
510
511
                else:
511
 
                    target = 'Doc\\Bazaar'
 
512
                    target = 'Doc\\Breezy'
512
513
                docs.append((target, r))
513
514
        return docs
514
515
 
515
516
    # python's distutils-based win32 installer
516
 
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
517
    ARGS = {'scripts': ['brz', 'tools/win32/brz-win32-bdist-postinstall.py'],
517
518
            'ext_modules': ext_modules,
518
519
            # help pages
519
520
            'data_files': find_docs(),
523
524
 
524
525
    ARGS.update(META_INFO)
525
526
    ARGS.update(BZRLIB)
526
 
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
 
527
    PKG_DATA['package_data']['breezy'].append('locale/*/LC_MESSAGES/*.mo')
527
528
    ARGS.update(PKG_DATA)
528
529
 
529
530
    setup(**ARGS)
532
533
    # py2exe setup
533
534
    import py2exe
534
535
 
535
 
    # pick real bzr version
536
 
    import bzrlib
 
536
    # pick real brz version
 
537
    import breezy
537
538
 
538
539
    version_number = []
539
 
    for i in bzrlib.version_info[:4]:
 
540
    for i in breezy.version_info[:4]:
540
541
        try:
541
542
            i = int(i)
542
543
        except ValueError:
574
575
            self.outfiles.extend([f + 'o' for f in compile_names])
575
576
    # end of class install_data_with_bytecompile
576
577
 
577
 
    target = py2exe.build_exe.Target(script = "bzr",
578
 
                                     dest_base = "bzr",
579
 
                                     icon_resources = [(0,'bzr.ico')],
 
578
    target = py2exe.build_exe.Target(script = "brz",
 
579
                                     dest_base = "brz",
 
580
                                     icon_resources = [(0,'brz.ico')],
580
581
                                     name = META_INFO['name'],
581
582
                                     version = version_str,
582
583
                                     description = META_INFO['description'],
589
590
    gui_target.dest_base = "bzrw"
590
591
 
591
592
    packages = BZRLIB['packages']
592
 
    packages.remove('bzrlib')
593
 
    packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
 
593
    packages.remove('breezy')
 
594
    packages = [i for i in packages if not i.startswith('breezy.plugins')]
594
595
    includes = []
595
 
    for i in glob.glob('bzrlib\\*.py'):
 
596
    for i in glob.glob('breezy\\*.py'):
596
597
        module = i[:-3].replace('\\', '.')
597
598
        if module.endswith('__init__'):
598
599
            module = module[:-len('__init__')]
633
634
        excludes.append("email.MIME" + oldname)
634
635
 
635
636
    # text files for help topis
636
 
    text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
 
637
    text_topics = glob.glob('breezy/help_topics/en/*.txt')
637
638
    topics_files = [('lib/help_topics/en', text_topics)]
638
639
 
639
640
    # built-in plugins
642
643
    # which hard-codes the list of plugins, gets more upset if modules are
643
644
    # missing, etc?
644
645
    plugins = None # will be a set after plugin sniffing...
645
 
    for root, dirs, files in os.walk('bzrlib/plugins'):
646
 
        if root == 'bzrlib/plugins':
 
646
    for root, dirs, files in os.walk('breezy/plugins'):
 
647
        if root == 'breezy/plugins':
647
648
            plugins = set(dirs)
648
649
            # We ship plugins as normal files on the file-system - however,
649
650
            # the build process can cause *some* of these plugin files to end
651
652
            # library.zip, and then saw import errors related to that as the
652
653
            # rest of the svn plugin wasn't. So we tell py2exe to leave the
653
654
            # plugins out of the .zip file
654
 
            excludes.extend(["bzrlib.plugins." + d for d in dirs])
 
655
            excludes.extend(["breezy.plugins." + d for d in dirs])
655
656
        x = []
656
657
        for i in files:
657
658
            # Throw away files we don't want packaged. Note that plugins may
660
661
            ext = os.path.splitext(i)[1]
661
662
            if ext.endswith('~') or ext in [".pyc", ".swp"]:
662
663
                continue
663
 
            if i == '__init__.py' and root == 'bzrlib/plugins':
 
664
            if i == '__init__.py' and root == 'breezy/plugins':
664
665
                continue
665
666
            x.append(os.path.join(root, i))
666
667
        if x:
667
 
            target_dir = root[len('bzrlib/'):]  # install to 'plugins/...'
 
668
            target_dir = root[len('breezy/'):]  # install to 'plugins/...'
668
669
            plugins_files.append((target_dir, x))
669
670
    # find modules for built-in plugins
670
671
    import tools.package_mf
671
672
    mf = tools.package_mf.CustomModuleFinder()
672
 
    mf.run_package('bzrlib/plugins')
 
673
    mf.run_package('breezy/plugins')
673
674
    packs, mods = mf.get_result()
674
675
    additional_packages.update(packs)
675
676
    includes.extend(mods)
761
762
    # ad-hoc for easy_install
762
763
    DATA_FILES = []
763
764
    if not 'bdist_egg' in sys.argv:
764
 
        # generate and install bzr.1 only with plain install, not the
 
765
        # generate and install brz.1 only with plain install, not the
765
766
        # easy_install one
766
 
        DATA_FILES = [('man/man1', ['bzr.1'])]
 
767
        DATA_FILES = [('man/man1', ['brz.1'])]
767
768
 
768
769
    DATA_FILES = DATA_FILES + I18N_FILES
769
770
    # std setup
770
 
    ARGS = {'scripts': ['bzr'],
 
771
    ARGS = {'scripts': ['brz'],
771
772
            'data_files': DATA_FILES,
772
773
            'cmdclass': command_classes,
773
774
            'ext_modules': ext_modules,