/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: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
 
1
#! /usr/bin/env python3
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")
17
 
    sys.exit(1)
 
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 as e:
 
23
    sys.stderr.write("[ERROR] Please install setuptools (%s)\n" % e)
 
24
    sys.exit(1)
 
25
 
18
26
 
19
27
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
20
28
# './setup.py' or the equivalent with another path, should always be at the
21
29
# start of the path, so this should find the right one...
22
 
import bzrlib
 
30
import breezy
23
31
 
24
32
def get_long_description():
25
33
    dirname = os.path.dirname(__file__)
26
 
    readme = os.path.join(dirname, 'README')
27
 
    f = open(readme, 'rb')
28
 
    try:
 
34
    readme = os.path.join(dirname, 'README.rst')
 
35
    with open(readme, 'r') as f:
29
36
        return f.read()
30
 
    finally:
31
 
        f.close()
32
37
 
33
38
 
34
39
##
35
40
# META INFORMATION FOR SETUP
36
41
# see http://docs.python.org/dist/meta-data.html
37
42
META_INFO = {
38
 
    'name':         'bzr',
39
 
    'version':      bzrlib.__version__,
40
 
    'author':       'Canonical Ltd',
41
 
    'author_email': 'bazaar@lists.canonical.com',
42
 
    'url':          'http://bazaar.canonical.com/',
43
 
    'description':  'Friendly distributed version control system',
44
 
    'license':      'GNU GPL v2',
45
 
    'download_url': 'https://launchpad.net/bzr/+download',
 
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',
 
50
    'download_url': 'https://launchpad.net/brz/+download',
46
51
    'long_description': get_long_description(),
47
52
    'classifiers': [
48
53
        'Development Status :: 6 - Mature',
57
62
        'Programming Language :: C',
58
63
        'Topic :: Software Development :: Version Control',
59
64
        ],
 
65
    '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"',
 
72
        ],
 
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
}
 
85
 
 
86
# The list of packages is automatically generated later. Add other things
 
87
# that are part of BREEZY here.
 
88
BREEZY = {}
 
89
 
 
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
                                ]},
60
100
    }
61
 
 
62
 
# The list of packages is automatically generated later. Add other things
63
 
# that are part of BZRLIB here.
64
 
BZRLIB = {}
65
 
 
66
 
PKG_DATA = {# install files from selftest suite
67
 
            'package_data': {'bzrlib': ['doc/api/*.txt',
68
 
                                        'tests/test_patches_data/*',
69
 
                                        'help_topics/en/*.txt',
70
 
                                        'tests/ssl_certs/ca.crt',
71
 
                                        'tests/ssl_certs/server_without_pass.key',
72
 
                                        'tests/ssl_certs/server_with_pass.key',
73
 
                                        'tests/ssl_certs/server.crt',
74
 
                                       ]},
75
 
           }
76
101
I18N_FILES = []
77
 
for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
78
 
    langfile = filepath[len("bzrlib/locale/"):]
 
102
for filepath in glob.glob("breezy/locale/*/LC_MESSAGES/*.mo"):
 
103
    langfile = filepath[len("breezy/locale/"):]
79
104
    targetpath = os.path.dirname(os.path.join("share/locale", langfile))
80
105
    I18N_FILES.append((targetpath, [filepath]))
81
106
 
82
 
def get_bzrlib_packages():
83
 
    """Recurse through the bzrlib directory, and extract the package names"""
 
107
def get_breezy_packages():
 
108
    """Recurse through the breezy directory, and extract the package names"""
84
109
 
85
110
    packages = []
86
 
    base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
 
111
    base_path = os.path.dirname(os.path.abspath(breezy.__file__))
87
112
    for root, dirs, files in os.walk(base_path):
88
113
        if '__init__.py' in files:
89
114
            assert root.startswith(base_path)
90
 
            # Get just the path below bzrlib
 
115
            # Get just the path below breezy
91
116
            package_path = root[len(base_path):]
92
117
            # Remove leading and trailing slashes
93
118
            package_path = package_path.strip('\\/')
94
119
            if not package_path:
95
 
                package_name = 'bzrlib'
 
120
                package_name = 'breezy'
96
121
            else:
97
 
                package_name = ('bzrlib.' +
98
 
                            package_path.replace('/', '.').replace('\\', '.'))
 
122
                package_name = (
 
123
                    'breezy.' +
 
124
                    package_path.replace('/', '.').replace('\\', '.'))
99
125
            packages.append(package_name)
100
126
    return sorted(packages)
101
127
 
102
128
 
103
 
BZRLIB['packages'] = get_bzrlib_packages()
104
 
 
105
 
 
106
 
from distutils import log
107
 
from distutils.core import setup
 
129
BREEZY['packages'] = get_breezy_packages()
 
130
 
 
131
 
 
132
from setuptools import setup
108
133
from distutils.version import LooseVersion
109
134
from distutils.command.install_scripts import install_scripts
110
135
from distutils.command.install_data import install_data
116
141
 
117
142
class my_install_scripts(install_scripts):
118
143
    """ Customized install_scripts distutils action.
119
 
    Create bzr.bat for win32.
 
144
    Create brz.bat for win32.
120
145
    """
121
146
    def run(self):
122
147
        install_scripts.run(self)   # standard action
125
150
            try:
126
151
                scripts_dir = os.path.join(sys.prefix, 'Scripts')
127
152
                script_path = self._quoted_path(os.path.join(scripts_dir,
128
 
                                                             "bzr"))
 
153
                                                             "brz"))
129
154
                python_exe = self._quoted_path(sys.executable)
130
 
                args = self._win_batch_args()
131
 
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
132
 
                batch_path = os.path.join(self.install_dir, "bzr.bat")
133
 
                f = file(batch_path, "w")
134
 
                f.write(batch_str)
135
 
                f.close()
136
 
                print("Created: %s" % batch_path)
 
155
                batch_str = "@%s %s %%*" % (python_exe, script_path)
 
156
                batch_path = os.path.join(self.install_dir, "brz.bat")
 
157
                with open(batch_path, "w") as f:
 
158
                    f.write(batch_str)
 
159
                print(("Created: %s" % batch_path))
137
160
            except Exception:
138
161
                e = sys.exc_info()[1]
139
 
                print("ERROR: Unable to create %s: %s" % (batch_path, e))
 
162
                print(("ERROR: Unable to create %s: %s" % (batch_path, e)))
140
163
 
141
164
    def _quoted_path(self, path):
142
165
        if ' ' in path:
143
166
            return '"' + path + '"'
144
167
        else:
145
168
            return path
146
 
 
147
 
    def _win_batch_args(self):
148
 
        from bzrlib.win32utils import winver
149
 
        if winver == 'Windows NT':
150
 
            return '%*'
151
 
        else:
152
 
            return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
153
169
#/class my_install_scripts
154
170
 
155
171
 
156
172
class bzr_build(build):
157
173
    """Customized build distutils action.
158
 
    Generate bzr.1.
 
174
    Generate brz.1.
159
175
    """
160
176
 
161
177
    sub_commands = build.sub_commands + [
162
 
            ('build_mo', lambda _: True),
163
 
            ]
 
178
        ('build_mo', lambda _: True),
 
179
        ]
164
180
 
165
181
    def run(self):
166
182
        build.run(self)
167
183
 
168
184
        from tools import generate_docs
169
 
        generate_docs.main(argv=["bzr", "man"])
 
185
        generate_docs.main(argv=["brz", "man"])
170
186
 
171
187
 
172
188
########################
173
189
## Setup
174
190
########################
175
191
 
176
 
from bzrlib.bzr_distutils import build_mo
 
192
from breezy.bzr_distutils import build_mo
177
193
 
178
194
command_classes = {'install_scripts': my_install_scripts,
179
195
                   'build': bzr_build,
184
200
from distutils.extension import Extension
185
201
ext_modules = []
186
202
try:
187
 
    try:
188
 
        from Cython.Distutils import build_ext
189
 
        from Cython.Compiler.Version import version as pyrex_version
190
 
    except ImportError:
191
 
        print("No Cython, trying Pyrex...")
192
 
        from Pyrex.Distutils import build_ext
193
 
        from Pyrex.Compiler.Version import version as pyrex_version
 
203
    from Cython.Distutils import build_ext
 
204
    from Cython.Compiler.Version import version as cython_version
194
205
except ImportError:
195
 
    have_pyrex = False
 
206
    have_cython = False
196
207
    # try to build the extension from the prior generated source.
197
208
    print("")
198
 
    print("The python package 'Pyrex' is not available."
 
209
    print("The python package 'Cython' is not available."
199
210
          " If the .c files are available,")
200
211
    print("they will be built,"
201
212
          " but modifying the .pyx files will not rebuild them.")
202
213
    print("")
203
214
    from distutils.command.build_ext import build_ext
204
215
else:
205
 
    have_pyrex = True
206
 
    pyrex_version_info = LooseVersion(pyrex_version)
 
216
    minimum_cython_version = '0.29'
 
217
    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
207
227
 
208
228
 
209
229
class build_ext_if_possible(build_ext):
247
267
                     % (ext.name,))
248
268
 
249
269
 
250
 
# Override the build_ext if we have Pyrex available
 
270
# Override the build_ext if we have Cython available
251
271
command_classes['build_ext'] = build_ext_if_possible
252
272
unavailable_files = []
253
273
 
254
274
 
255
 
def add_pyrex_extension(module_name, libraries=None, extra_source=[]):
256
 
    """Add a pyrex module to build.
 
275
def add_cython_extension(module_name, libraries=None, extra_source=[]):
 
276
    """Add a cython module to build.
257
277
 
258
 
    This will use Pyrex to auto-generate the .c file if it is available.
 
278
    This will use Cython to auto-generate the .c file if it is available.
259
279
    Otherwise it will fall back on the .c file. If the .c file is not
260
280
    available, it will warn, and not add anything.
261
281
 
266
286
        determine the .pyx and .c files to use.
267
287
    """
268
288
    path = module_name.replace('.', '/')
269
 
    pyrex_name = path + '.pyx'
 
289
    cython_name = path + '.pyx'
270
290
    c_name = path + '.c'
271
291
    define_macros = []
272
292
    if sys.platform == 'win32':
273
 
        # pyrex uses the macro WIN32 to detect the platform, even though it
 
293
        # cython uses the macro WIN32 to detect the platform, even though it
274
294
        # should be using something like _WIN32 or MS_WINDOWS, oh well, we can
275
295
        # give it the right value.
276
296
        define_macros.append(('WIN32', None))
277
 
    if have_pyrex:
278
 
        source = [pyrex_name]
 
297
    if have_cython:
 
298
        source = [cython_name]
279
299
    else:
280
300
        if not os.path.isfile(c_name):
281
301
            unavailable_files.append(c_name)
283
303
        else:
284
304
            source = [c_name]
285
305
    source.extend(extra_source)
286
 
    ext_modules.append(Extension(module_name, source,
287
 
        define_macros=define_macros, libraries=libraries))
288
 
 
289
 
 
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')
 
306
    include_dirs = ['breezy']
 
307
    ext_modules.append(
 
308
        Extension(
 
309
            module_name, source, define_macros=define_macros,
 
310
            libraries=libraries, include_dirs=include_dirs))
 
311
 
 
312
 
 
313
add_cython_extension('breezy._simple_set_pyx')
 
314
ext_modules.append(Extension('breezy._static_tuple_c',
 
315
                             ['breezy/_static_tuple_c.c']))
 
316
add_cython_extension('breezy._annotator_pyx')
 
317
add_cython_extension('breezy._bencode_pyx')
 
318
add_cython_extension('breezy._chunks_to_lines_pyx')
 
319
add_cython_extension('breezy.bzr._groupcompress_pyx',
 
320
                     extra_source=['breezy/bzr/diff-delta.c'])
 
321
add_cython_extension('breezy.bzr._knit_load_data_pyx')
 
322
add_cython_extension('breezy._known_graph_pyx')
 
323
add_cython_extension('breezy._rio_pyx')
298
324
if sys.platform == 'win32':
299
 
    add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
300
 
                        libraries=['Ws2_32'])
301
 
    add_pyrex_extension('bzrlib._walkdirs_win32')
302
 
else:
303
 
    if have_pyrex and pyrex_version_info == LooseVersion("0.9.4.1"):
304
 
        # Pyrex 0.9.4.1 fails to compile this extension correctly
305
 
        # The code it generates re-uses a "local" pointer and
306
 
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
307
 
        # which is NULL safe with PY_DECREF which is not.)
308
 
        # <https://bugs.launchpad.net/bzr/+bug/449372>
309
 
        # <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,))
313
 
        print('install. For now, the non-compiled (python) version will')
314
 
        print('be used instead.')
315
 
    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']))
321
 
if have_pyrex and pyrex_version_info < LooseVersion("0.9.6.3"):
322
 
    print("")
323
 
    print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
324
 
        pyrex_version))
325
 
    print('and static_tuple extensions.')
326
 
    print('Please upgrade to at least Pyrex 0.9.6.3')
327
 
    print("")
328
 
    # TODO: Should this be a fatal error?
329
 
else:
330
 
    # We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
331
 
    # 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')
 
325
    add_cython_extension('breezy.bzr._dirstate_helpers_pyx',
 
326
                         libraries=['Ws2_32'])
 
327
    add_cython_extension('breezy._walkdirs_win32')
 
328
else:
 
329
    add_cython_extension('breezy.bzr._dirstate_helpers_pyx')
 
330
    add_cython_extension('breezy._readdir_pyx')
 
331
add_cython_extension('breezy.bzr._chk_map_pyx')
 
332
add_cython_extension('breezy.bzr._btree_serializer_pyx')
336
333
 
337
334
 
338
335
if unavailable_files:
339
336
    print('C extension(s) not found:')
340
 
    print('   %s' % ('\n  '.join(unavailable_files),))
 
337
    print(('   %s' % ('\n  '.join(unavailable_files),)))
341
338
    print('The python versions will be used instead.')
342
339
    print("")
343
340
 
362
359
    # TBZR points to the TBZR directory
363
360
    tbzr_root = os.environ["TBZR"]
364
361
 
365
 
    # Ensure tbzrlib itself is on sys.path
 
362
    # Ensure tbreezy itself is on sys.path
366
363
    sys.path.append(tbzr_root)
367
364
 
368
 
    packages.append("tbzrlib")
 
365
    packages.append("tbreezy")
369
366
 
370
367
    # collect up our icons.
371
368
    cwd = os.getcwd()
372
 
    ico_root = os.path.join(tbzr_root, 'tbzrlib', 'resources')
 
369
    ico_root = os.path.join(tbzr_root, 'tbreezy', 'resources')
373
370
    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'))
 
371
    # First always brz's icon and its in the root of the brz tree.
 
372
    icos.append(('', 'brz.ico'))
376
373
    for root, dirs, files in os.walk(ico_root):
377
 
        icos.extend([(ico_root, os.path.join(root, f)[len(ico_root)+1:])
 
374
        icos.extend([(ico_root, os.path.join(root, f)[len(ico_root) + 1:])
378
375
                     for f in files if f.endswith('.ico')])
379
376
    # allocate an icon ID for each file and the full path to the ico
380
377
    icon_resources = [(rid, os.path.join(ico_dir, ico_name))
387
384
                 for rid, (_, f) in enumerate(icos)]
388
385
    ico_map = dict(map_items)
389
386
    # Create a new resource type of 'ICON_MAP', and use ID=1
390
 
    other_resources = [ ("ICON_MAP", 1, pickle.dumps(ico_map))]
 
387
    other_resources = [("ICON_MAP", 1, pickle.dumps(ico_map))]
391
388
 
392
389
    excludes.extend("""pywin pywin.dialogs pywin.dialogs.list
393
390
                       win32ui crawler.Crawler""".split())
395
392
    # tbzrcache executables - a "console" version for debugging and a
396
393
    # GUI version that is generally used.
397
394
    tbzrcache = dict(
398
 
        script = os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
399
 
        icon_resources = icon_resources,
400
 
        other_resources = other_resources,
 
395
        script=os.path.join(tbzr_root, "scripts", "tbzrcache.py"),
 
396
        icon_resources=icon_resources,
 
397
        other_resources=other_resources,
401
398
    )
402
399
    console_targets.append(tbzrcache)
403
400
 
404
401
    # Make a windows version which is the same except for the base name.
405
402
    tbzrcachew = tbzrcache.copy()
406
 
    tbzrcachew["dest_base"]="tbzrcachew"
 
403
    tbzrcachew["dest_base"] = "tbzrcachew"
407
404
    gui_targets.append(tbzrcachew)
408
405
 
409
406
    # ditto for the tbzrcommand tool
410
407
    tbzrcommand = dict(
411
 
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
412
 
        icon_resources = icon_resources,
413
 
        other_resources = other_resources,
 
408
        script=os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
 
409
        icon_resources=icon_resources,
 
410
        other_resources=other_resources,
414
411
    )
415
412
    console_targets.append(tbzrcommand)
416
413
    tbzrcommandw = tbzrcommand.copy()
417
 
    tbzrcommandw["dest_base"]="tbzrcommandw"
 
414
    tbzrcommandw["dest_base"] = "tbzrcommandw"
418
415
    gui_targets.append(tbzrcommandw)
419
 
    
 
416
 
420
417
    # A utility to see python output from both C++ and Python based shell
421
418
    # extensions
422
419
    tracer = dict(script=os.path.join(tbzr_root, "scripts", "tbzrtrace.py"))
490
487
 
491
488
def get_fastimport_py2exe_info(includes, excludes, packages):
492
489
    # This is the python-fastimport package, not to be confused with the
493
 
    # bzr-fastimport plugin.
 
490
    # brz-fastimport plugin.
494
491
    packages.append('fastimport')
495
492
 
496
493
 
500
497
        for root, dirs, files in os.walk('doc'):
501
498
            r = []
502
499
            for f in files:
503
 
                if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
504
 
                    or f == 'quick-start-summary.svg'):
 
500
                if (os.path.splitext(f)[1] in ('.html', '.css', '.png', '.pdf')
 
501
                        or f == 'quick-start-summary.svg'):
505
502
                    r.append(os.path.join(root, f))
506
503
            if r:
507
504
                relative = root[4:]
508
505
                if relative:
509
 
                    target = os.path.join('Doc\\Bazaar', relative)
 
506
                    target = os.path.join('Doc\\Breezy', relative)
510
507
                else:
511
 
                    target = 'Doc\\Bazaar'
 
508
                    target = 'Doc\\Breezy'
512
509
                docs.append((target, r))
513
510
        return docs
514
511
 
515
512
    # python's distutils-based win32 installer
516
 
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
513
    ARGS = {'scripts': ['brz', 'tools/win32/brz-win32-bdist-postinstall.py'],
517
514
            'ext_modules': ext_modules,
518
515
            # help pages
519
516
            'data_files': find_docs(),
520
 
            # for building pyrex extensions
 
517
            # for building cython extensions
521
518
            'cmdclass': command_classes,
522
 
           }
 
519
            }
523
520
 
524
521
    ARGS.update(META_INFO)
525
 
    ARGS.update(BZRLIB)
526
 
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
 
522
    ARGS.update(BREEZY)
 
523
    PKG_DATA['package_data']['breezy'].append('locale/*/LC_MESSAGES/*.mo')
527
524
    ARGS.update(PKG_DATA)
528
525
 
529
526
    setup(**ARGS)
532
529
    # py2exe setup
533
530
    import py2exe
534
531
 
535
 
    # pick real bzr version
536
 
    import bzrlib
 
532
    # pick real brz version
 
533
    import breezy
537
534
 
538
535
    version_number = []
539
 
    for i in bzrlib.version_info[:4]:
 
536
    for i in breezy.version_info[:4]:
540
537
        try:
541
538
            i = int(i)
542
539
        except ValueError:
574
571
            self.outfiles.extend([f + 'o' for f in compile_names])
575
572
    # end of class install_data_with_bytecompile
576
573
 
577
 
    target = py2exe.build_exe.Target(script = "bzr",
578
 
                                     dest_base = "bzr",
579
 
                                     icon_resources = [(0,'bzr.ico')],
580
 
                                     name = META_INFO['name'],
581
 
                                     version = version_str,
582
 
                                     description = META_INFO['description'],
583
 
                                     author = META_INFO['author'],
584
 
                                     copyright = "(c) Canonical Ltd, 2005-2010",
585
 
                                     company_name = "Canonical Ltd.",
586
 
                                     comments = META_INFO['description'],
587
 
                                    )
 
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
    )
588
586
    gui_target = copy.copy(target)
589
587
    gui_target.dest_base = "bzrw"
590
588
 
591
 
    packages = BZRLIB['packages']
592
 
    packages.remove('bzrlib')
593
 
    packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
 
589
    packages = BREEZY['packages']
 
590
    packages.remove('breezy')
 
591
    packages = [i for i in packages if not i.startswith('breezy.plugins')]
594
592
    includes = []
595
 
    for i in glob.glob('bzrlib\\*.py'):
 
593
    for i in glob.glob('breezy\\*.py'):
596
594
        module = i[:-3].replace('\\', '.')
597
595
        if module.endswith('__init__'):
598
596
            module = module[:-len('__init__')]
599
597
        includes.append(module)
600
598
 
601
599
    additional_packages = set()
602
 
    if sys.version.startswith('2.4'):
603
 
        # adding elementtree package
604
 
        additional_packages.add('elementtree')
605
 
    elif sys.version.startswith('2.6') or sys.version.startswith('2.5'):
606
 
        additional_packages.add('xml.etree')
607
 
    else:
608
 
        import warnings
609
 
        warnings.warn('Unknown Python version.\n'
610
 
                      'Please check setup.py script for compatibility.')
611
600
 
612
601
    # Although we currently can't enforce it, we consider it an error for
613
602
    # py2exe to report any files are "missing".  Such modules we know aren't
615
604
    excludes = """Tkinter psyco ElementPath r_hmac
616
605
                  ImaginaryModule cElementTree elementtree.ElementTree
617
606
                  Crypto.PublicKey._fastmath
618
 
                  medusa medusa.filesys medusa.ftp_server
619
607
                  tools
620
608
                  resource validate""".split()
621
609
    dll_excludes = []
633
621
        excludes.append("email.MIME" + oldname)
634
622
 
635
623
    # text files for help topis
636
 
    text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
 
624
    text_topics = glob.glob('breezy/help_topics/en/*.txt')
637
625
    topics_files = [('lib/help_topics/en', text_topics)]
638
626
 
639
627
    # built-in plugins
642
630
    # which hard-codes the list of plugins, gets more upset if modules are
643
631
    # missing, etc?
644
632
    plugins = None # will be a set after plugin sniffing...
645
 
    for root, dirs, files in os.walk('bzrlib/plugins'):
646
 
        if root == 'bzrlib/plugins':
 
633
    for root, dirs, files in os.walk('breezy/plugins'):
 
634
        if root == 'breezy/plugins':
647
635
            plugins = set(dirs)
648
636
            # We ship plugins as normal files on the file-system - however,
649
637
            # the build process can cause *some* of these plugin files to end
651
639
            # library.zip, and then saw import errors related to that as the
652
640
            # rest of the svn plugin wasn't. So we tell py2exe to leave the
653
641
            # plugins out of the .zip file
654
 
            excludes.extend(["bzrlib.plugins." + d for d in dirs])
 
642
            excludes.extend(["breezy.plugins." + d for d in dirs])
655
643
        x = []
656
644
        for i in files:
657
645
            # Throw away files we don't want packaged. Note that plugins may
660
648
            ext = os.path.splitext(i)[1]
661
649
            if ext.endswith('~') or ext in [".pyc", ".swp"]:
662
650
                continue
663
 
            if i == '__init__.py' and root == 'bzrlib/plugins':
 
651
            if i == '__init__.py' and root == 'breezy/plugins':
664
652
                continue
665
653
            x.append(os.path.join(root, i))
666
654
        if x:
667
 
            target_dir = root[len('bzrlib/'):]  # install to 'plugins/...'
 
655
            target_dir = root[len('breezy/'):]  # install to 'plugins/...'
668
656
            plugins_files.append((target_dir, x))
669
657
    # find modules for built-in plugins
670
658
    import tools.package_mf
671
659
    mf = tools.package_mf.CustomModuleFinder()
672
 
    mf.run_package('bzrlib/plugins')
 
660
    mf.run_package('breezy/plugins')
673
661
    packs, mods = mf.get_result()
674
662
    additional_packages.update(packs)
675
663
    includes.extend(mods)
717
705
        # at build time.  Also to stdout so it appears in the log
718
706
        for f in (sys.stderr, sys.stdout):
719
707
            f.write("Skipping TBZR binaries - "
720
 
                "please set TBZR to a directory to enable\n")
 
708
                    "please set TBZR to a directory to enable\n")
721
709
 
722
710
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
723
711
    # in on Vista.
733
721
                               "dist_dir": "win32_bzr.exe",
734
722
                               "optimize": 2,
735
723
                               "custom_boot_script":
736
 
                                        "tools/win32/py2exe_boot_common.py",
737
 
                              },
738
 
                   }
 
724
                                   "tools/win32/py2exe_boot_common.py",
 
725
                               },
 
726
                    }
739
727
 
740
728
    # We want the libaray.zip to have optimize = 2, but the exe to have
741
729
    # optimize = 1, so that .py files that get compilied at run time
760
748
else:
761
749
    # ad-hoc for easy_install
762
750
    DATA_FILES = []
763
 
    if not 'bdist_egg' in sys.argv:
764
 
        # generate and install bzr.1 only with plain install, not the
 
751
    if 'bdist_egg' not in sys.argv:
 
752
        # generate and install brz.1 only with plain install, not the
765
753
        # easy_install one
766
 
        DATA_FILES = [('man/man1', ['bzr.1'])]
 
754
        DATA_FILES = [('man/man1', ['brz.1', 'breezy/git/git-remote-bzr.1'])]
767
755
 
768
756
    DATA_FILES = DATA_FILES + I18N_FILES
769
757
    # std setup
770
 
    ARGS = {'scripts': ['bzr'],
 
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'],
771
764
            'data_files': DATA_FILES,
772
765
            'cmdclass': command_classes,
773
766
            'ext_modules': ext_modules,
774
 
           }
 
767
            }
775
768
 
776
769
    ARGS.update(META_INFO)
777
 
    ARGS.update(BZRLIB)
 
770
    ARGS.update(BREEZY)
778
771
    ARGS.update(PKG_DATA)
779
772
 
780
773
    if __name__ == '__main__':