/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-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

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
12
12
import copy
13
13
import glob
14
14
 
15
 
if sys.version_info < (3, 5):
16
 
    sys.stderr.write("[ERROR] Not a supported Python version. Need 3.5+\n")
17
 
    sys.exit(1)
18
 
 
19
 
 
20
 
try:
21
 
    import setuptools
22
 
except ImportError:
23
 
    sys.stderr.write("[ERROR] Please install setuptools\n")
24
 
    sys.exit(1)
25
 
 
 
15
if sys.version_info < (2, 7):
 
16
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.7+\n")
 
17
    sys.exit(1)
26
18
 
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
31
23
 
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')
 
28
    try:
36
29
        return f.read()
 
30
    finally:
 
31
        f.close()
37
32
 
38
33
 
39
34
##
40
35
# META INFORMATION FOR SETUP
41
36
# see http://docs.python.org/dist/meta-data.html
42
37
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',
 
38
    'name':         'breezy',
 
39
    'version':      breezy.__version__,
 
40
    'maintainer':   'Breezy Developers',
 
41
    'maintainer_email':   'team@breezy-vcs.org',
 
42
    'url':          'https://www.breezy-vcs.org/',
 
43
    'description':  'Friendly distributed version control system',
 
44
    'license':      'GNU GPL v2',
50
45
    'download_url': 'https://launchpad.net/brz/+download',
51
46
    'long_description': get_long_description(),
52
47
    'classifiers': [
63
58
        'Topic :: Software Development :: Version Control',
64
59
        ],
65
60
    'install_requires': [
66
 
        'configobj',
67
 
        'patiencediff',
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"',
 
61
        'six>=1.9.0',
72
62
        ],
73
 
    'extras_require': {
74
 
        'fastimport': [],
75
 
        'git': [],
76
 
        'launchpad': ['launchpadlib>=1.6.3'],
77
 
        'workspace': ['pyinotify'],
78
 
        },
79
 
    'tests_require': [
80
 
        'testtools',
81
 
        'testtools<=2.4.0;python_version<"3.0"',
82
 
        'python-subunit',
83
 
    ],
84
 
}
 
63
    }
85
64
 
86
65
# The list of packages is automatically generated later. Add other things
87
 
# that are part of BREEZY here.
88
 
BREEZY = {}
 
66
# that are part of BZRLIB here.
 
67
BZRLIB = {}
89
68
 
90
 
PKG_DATA = {
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',
99
 
                                ]},
100
 
    }
 
69
PKG_DATA = {# install files from selftest suite
 
70
            'package_data': {'breezy': ['doc/api/*.txt',
 
71
                                        'tests/test_patches_data/*',
 
72
                                        'help_topics/en/*.txt',
 
73
                                        'tests/ssl_certs/ca.crt',
 
74
                                        'tests/ssl_certs/server_without_pass.key',
 
75
                                        'tests/ssl_certs/server_with_pass.key',
 
76
                                        'tests/ssl_certs/server.crt',
 
77
                                       ]},
 
78
           }
101
79
I18N_FILES = []
102
80
for filepath in glob.glob("breezy/locale/*/LC_MESSAGES/*.mo"):
103
81
    langfile = filepath[len("breezy/locale/"):]
119
97
            if not package_path:
120
98
                package_name = 'breezy'
121
99
            else:
122
 
                package_name = (
123
 
                    'breezy.' +
124
 
                    package_path.replace('/', '.').replace('\\', '.'))
 
100
                package_name = ('breezy.' +
 
101
                            package_path.replace('/', '.').replace('\\', '.'))
125
102
            packages.append(package_name)
126
103
    return sorted(packages)
127
104
 
128
105
 
129
 
BREEZY['packages'] = get_breezy_packages()
130
 
 
131
 
 
132
 
from setuptools import setup
 
106
BZRLIB['packages'] = get_breezy_packages()
 
107
 
 
108
 
 
109
from distutils import log
 
110
from distutils.core import setup
133
111
from distutils.version import LooseVersion
134
112
from distutils.command.install_scripts import install_scripts
135
113
from distutils.command.install_data import install_data
152
130
                script_path = self._quoted_path(os.path.join(scripts_dir,
153
131
                                                             "brz"))
154
132
                python_exe = self._quoted_path(sys.executable)
155
 
                batch_str = "@%s %s %%*" % (python_exe, script_path)
 
133
                args = self._win_batch_args()
 
134
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
156
135
                batch_path = os.path.join(self.install_dir, "brz.bat")
157
 
                with open(batch_path, "w") as f:
158
 
                    f.write(batch_str)
 
136
                f = file(batch_path, "w")
 
137
                f.write(batch_str)
 
138
                f.close()
159
139
                print(("Created: %s" % batch_path))
160
140
            except Exception:
161
141
                e = sys.exc_info()[1]
166
146
            return '"' + path + '"'
167
147
        else:
168
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'
169
156
#/class my_install_scripts
170
157
 
171
158
 
175
162
    """
176
163
 
177
164
    sub_commands = build.sub_commands + [
178
 
        ('build_mo', lambda _: True),
179
 
        ]
 
165
            ('build_mo', lambda _: True),
 
166
            ]
180
167
 
181
168
    def run(self):
182
169
        build.run(self)
213
200
    print("")
214
201
    from distutils.command.build_ext import build_ext
215
202
else:
216
 
    minimum_cython_version = '0.29'
 
203
    have_cython = True
217
204
    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.")
224
 
        have_cython = False
225
 
    else:
226
 
        have_cython = True
227
205
 
228
206
 
229
207
class build_ext_if_possible(build_ext):
304
282
            source = [c_name]
305
283
    source.extend(extra_source)
306
284
    include_dirs = ['breezy']
307
 
    ext_modules.append(
308
 
        Extension(
309
 
            module_name, source, define_macros=define_macros,
310
 
            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
288
 
312
289
 
313
290
add_cython_extension('breezy._simple_set_pyx')
317
294
add_cython_extension('breezy._bencode_pyx')
318
295
add_cython_extension('breezy._chunks_to_lines_pyx')
319
296
add_cython_extension('breezy.bzr._groupcompress_pyx',
320
 
                     extra_source=['breezy/bzr/diff-delta.c'])
 
297
                    extra_source=['breezy/bzr/diff-delta.c'])
321
298
add_cython_extension('breezy.bzr._knit_load_data_pyx')
322
299
add_cython_extension('breezy._known_graph_pyx')
323
300
add_cython_extension('breezy._rio_pyx')
324
301
if sys.platform == 'win32':
325
302
    add_cython_extension('breezy.bzr._dirstate_helpers_pyx',
326
 
                         libraries=['Ws2_32'])
 
303
                        libraries=['Ws2_32'])
327
304
    add_cython_extension('breezy._walkdirs_win32')
328
305
else:
329
306
    add_cython_extension('breezy.bzr._dirstate_helpers_pyx')
330
307
    add_cython_extension('breezy._readdir_pyx')
331
308
add_cython_extension('breezy.bzr._chk_map_pyx')
 
309
ext_modules.append(Extension('breezy._patiencediff_c',
 
310
                             ['breezy/_patiencediff_c.c']))
332
311
add_cython_extension('breezy.bzr._btree_serializer_pyx')
333
312
 
334
313
 
371
350
    # First always brz's icon and its in the root of the brz tree.
372
351
    icos.append(('', 'brz.ico'))
373
352
    for root, dirs, files in os.walk(ico_root):
374
 
        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:])
375
354
                     for f in files if f.endswith('.ico')])
376
355
    # allocate an icon ID for each file and the full path to the ico
377
356
    icon_resources = [(rid, os.path.join(ico_dir, ico_name))
384
363
                 for rid, (_, f) in enumerate(icos)]
385
364
    ico_map = dict(map_items)
386
365
    # Create a new resource type of 'ICON_MAP', and use ID=1
387
 
    other_resources = [("ICON_MAP", 1, pickle.dumps(ico_map))]
 
366
    other_resources = [ ("ICON_MAP", 1, pickle.dumps(ico_map))]
388
367
 
389
368
    excludes.extend("""pywin pywin.dialogs pywin.dialogs.list
390
369
                       win32ui crawler.Crawler""".split())
392
371
    # tbzrcache executables - a "console" version for debugging and a
393
372
    # GUI version that is generally used.
394
373
    tbzrcache = dict(
395
 
        script=os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
396
 
        icon_resources=icon_resources,
397
 
        other_resources=other_resources,
 
374
        script = os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
 
375
        icon_resources = icon_resources,
 
376
        other_resources = other_resources,
398
377
    )
399
378
    console_targets.append(tbzrcache)
400
379
 
401
380
    # Make a windows version which is the same except for the base name.
402
381
    tbzrcachew = tbzrcache.copy()
403
 
    tbzrcachew["dest_base"] = "tbzrcachew"
 
382
    tbzrcachew["dest_base"]="tbzrcachew"
404
383
    gui_targets.append(tbzrcachew)
405
384
 
406
385
    # ditto for the tbzrcommand tool
407
386
    tbzrcommand = dict(
408
 
        script=os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
409
 
        icon_resources=icon_resources,
410
 
        other_resources=other_resources,
 
387
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
 
388
        icon_resources = icon_resources,
 
389
        other_resources = other_resources,
411
390
    )
412
391
    console_targets.append(tbzrcommand)
413
392
    tbzrcommandw = tbzrcommand.copy()
414
 
    tbzrcommandw["dest_base"] = "tbzrcommandw"
 
393
    tbzrcommandw["dest_base"]="tbzrcommandw"
415
394
    gui_targets.append(tbzrcommandw)
416
 
 
 
395
    
417
396
    # A utility to see python output from both C++ and Python based shell
418
397
    # extensions
419
398
    tracer = dict(script=os.path.join(tbzr_root, "scripts", "tbzrtrace.py"))
497
476
        for root, dirs, files in os.walk('doc'):
498
477
            r = []
499
478
            for f in files:
500
 
                if (os.path.splitext(f)[1] in ('.html', '.css', '.png', '.pdf')
501
 
                        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'):
502
481
                    r.append(os.path.join(root, f))
503
482
            if r:
504
483
                relative = root[4:]
516
495
            'data_files': find_docs(),
517
496
            # for building cython extensions
518
497
            'cmdclass': command_classes,
519
 
            }
 
498
           }
520
499
 
521
500
    ARGS.update(META_INFO)
522
 
    ARGS.update(BREEZY)
 
501
    ARGS.update(BZRLIB)
523
502
    PKG_DATA['package_data']['breezy'].append('locale/*/LC_MESSAGES/*.mo')
524
503
    ARGS.update(PKG_DATA)
525
504
 
571
550
            self.outfiles.extend([f + 'o' for f in compile_names])
572
551
    # end of class install_data_with_bytecompile
573
552
 
574
 
    target = py2exe.build_exe.Target(
575
 
        script="brz",
576
 
        dest_base="brz",
577
 
        icon_resources=[(0, 'brz.ico')],
578
 
        name=META_INFO['name'],
579
 
        version=version_str,
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'],
585
 
    )
 
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
                                    )
586
564
    gui_target = copy.copy(target)
587
565
    gui_target.dest_base = "bzrw"
588
566
 
589
 
    packages = BREEZY['packages']
 
567
    packages = BZRLIB['packages']
590
568
    packages.remove('breezy')
591
569
    packages = [i for i in packages if not i.startswith('breezy.plugins')]
592
570
    includes = []
597
575
        includes.append(module)
598
576
 
599
577
    additional_packages = set()
 
578
    if sys.version.startswith('2.7'):
 
579
        additional_packages.add('xml.etree')
 
580
    else:
 
581
        import warnings
 
582
        warnings.warn('Unknown Python version.\n'
 
583
                      'Please check setup.py script for compatibility.')
600
584
 
601
585
    # Although we currently can't enforce it, we consider it an error for
602
586
    # py2exe to report any files are "missing".  Such modules we know aren't
705
689
        # at build time.  Also to stdout so it appears in the log
706
690
        for f in (sys.stderr, sys.stdout):
707
691
            f.write("Skipping TBZR binaries - "
708
 
                    "please set TBZR to a directory to enable\n")
 
692
                "please set TBZR to a directory to enable\n")
709
693
 
710
694
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
711
695
    # in on Vista.
721
705
                               "dist_dir": "win32_bzr.exe",
722
706
                               "optimize": 2,
723
707
                               "custom_boot_script":
724
 
                                   "tools/win32/py2exe_boot_common.py",
725
 
                               },
726
 
                    }
 
708
                                        "tools/win32/py2exe_boot_common.py",
 
709
                              },
 
710
                   }
727
711
 
728
712
    # We want the libaray.zip to have optimize = 2, but the exe to have
729
713
    # optimize = 1, so that .py files that get compilied at run time
748
732
else:
749
733
    # ad-hoc for easy_install
750
734
    DATA_FILES = []
751
 
    if 'bdist_egg' not in sys.argv:
 
735
    if not 'bdist_egg' in sys.argv:
752
736
        # generate and install brz.1 only with plain install, not the
753
737
        # easy_install one
754
 
        DATA_FILES = [('man/man1', ['brz.1', 'breezy/git/git-remote-bzr.1'])]
 
738
        DATA_FILES = [('man/man1', ['brz.1'])]
755
739
 
756
740
    DATA_FILES = DATA_FILES + I18N_FILES
757
741
    # std setup
758
 
    ARGS = {'scripts': ['brz',
759
 
                        # TODO(jelmer): Only install the git scripts if
760
 
                        # Dulwich was found.
761
 
                        'breezy/git/git-remote-bzr',
762
 
                        'breezy/git/bzr-receive-pack',
763
 
                        'breezy/git/bzr-upload-pack'],
 
742
    ARGS = {'scripts': ['brz'],
764
743
            'data_files': DATA_FILES,
765
744
            'cmdclass': command_classes,
766
745
            'ext_modules': ext_modules,
767
 
            }
 
746
           }
768
747
 
769
748
    ARGS.update(META_INFO)
770
 
    ARGS.update(BREEZY)
 
749
    ARGS.update(BZRLIB)
771
750
    ARGS.update(PKG_DATA)
772
751
 
773
752
    if __name__ == '__main__':