~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Patch Queue Manager
  • Date: 2014-02-12 18:22:22 UTC
  • mfrom: (6589.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20140212182222-beouo25gaf1cny76
(vila) The XDG Base Directory Specification uses the XDG_CACHE_HOME,
 not XDG_CACHE_DIR. (Andrew Starr-Bochicchio)

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import os
10
10
import os.path
11
11
import sys
 
12
import copy
 
13
import glob
12
14
 
13
 
if sys.version_info < (2, 4):
14
 
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.4+\n")
 
15
if sys.version_info < (2, 6):
 
16
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.6+\n")
15
17
    sys.exit(1)
16
18
 
17
19
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
37
39
    'version':      bzrlib.__version__,
38
40
    'author':       'Canonical Ltd',
39
41
    'author_email': 'bazaar@lists.canonical.com',
40
 
    'url':          'http://www.bazaar-vcs.org/',
 
42
    'url':          'http://bazaar.canonical.com/',
41
43
    'description':  'Friendly distributed version control system',
42
44
    'license':      'GNU GPL v2',
43
 
    'download_url': 'http://bazaar-vcs.org/Download',
 
45
    'download_url': 'https://launchpad.net/bzr/+download',
44
46
    'long_description': get_long_description(),
45
47
    'classifiers': [
46
48
        'Development Status :: 6 - Mature',
65
67
            'package_data': {'bzrlib': ['doc/api/*.txt',
66
68
                                        'tests/test_patches_data/*',
67
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',
68
74
                                       ]},
69
75
           }
70
 
 
 
76
I18N_FILES = []
 
77
for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
 
78
    langfile = filepath[len("bzrlib/locale/"):]
 
79
    targetpath = os.path.dirname(os.path.join("share/locale", langfile))
 
80
    I18N_FILES.append((targetpath, [filepath]))
71
81
 
72
82
def get_bzrlib_packages():
73
83
    """Recurse through the bzrlib directory, and extract the package names"""
93
103
BZRLIB['packages'] = get_bzrlib_packages()
94
104
 
95
105
 
 
106
from distutils import log
96
107
from distutils.core import setup
97
108
from distutils.command.install_scripts import install_scripts
98
109
from distutils.command.install_data import install_data
121
132
                f = file(batch_path, "w")
122
133
                f.write(batch_str)
123
134
                f.close()
124
 
                print "Created:", batch_path
125
 
            except Exception, e:
126
 
                print "ERROR: Unable to create %s: %s" % (batch_path, e)
 
135
                print("Created: %s" % batch_path)
 
136
            except Exception:
 
137
                e = sys.exc_info()[1]
 
138
                print("ERROR: Unable to create %s: %s" % (batch_path, e))
127
139
 
128
140
    def _quoted_path(self, path):
129
141
        if ' ' in path:
145
157
    Generate bzr.1.
146
158
    """
147
159
 
 
160
    sub_commands = build.sub_commands + [
 
161
            ('build_mo', lambda _: True),
 
162
            ]
 
163
 
148
164
    def run(self):
149
165
        build.run(self)
150
166
 
151
 
        import generate_docs
 
167
        from tools import generate_docs
152
168
        generate_docs.main(argv=["bzr", "man"])
153
169
 
154
170
 
156
172
## Setup
157
173
########################
158
174
 
 
175
from bzrlib.bzr_distutils import build_mo
 
176
 
159
177
command_classes = {'install_scripts': my_install_scripts,
160
 
                   'build': bzr_build}
 
178
                   'build': bzr_build,
 
179
                   'build_mo': build_mo,
 
180
                   }
161
181
from distutils import log
162
182
from distutils.errors import CCompilerError, DistutilsPlatformError
163
183
from distutils.extension import Extension
164
184
ext_modules = []
165
185
try:
166
 
    from Pyrex.Distutils import build_ext
 
186
    try:
 
187
        from Cython.Distutils import build_ext
 
188
        from Cython.Compiler.Version import version as pyrex_version
 
189
    except ImportError:
 
190
        print("No Cython, trying Pyrex...")
 
191
        from Pyrex.Distutils import build_ext
 
192
        from Pyrex.Compiler.Version import version as pyrex_version
167
193
except ImportError:
168
194
    have_pyrex = False
169
195
    # try to build the extension from the prior generated source.
170
 
    print
171
 
    print ("The python package 'Pyrex' is not available."
172
 
           " If the .c files are available,")
173
 
    print ("they will be built,"
174
 
           " but modifying the .pyx files will not rebuild them.")
175
 
    print
 
196
    print("")
 
197
    print("The python package 'Pyrex' is not available."
 
198
          " If the .c files are available,")
 
199
    print("they will be built,"
 
200
          " but modifying the .pyx files will not rebuild them.")
 
201
    print("")
176
202
    from distutils.command.build_ext import build_ext
177
203
else:
178
204
    have_pyrex = True
179
 
    from Pyrex.Compiler.Version import version as pyrex_version
 
205
    pyrex_version_info = tuple(map(int, pyrex_version.rstrip("+").split('.')))
180
206
 
181
207
 
182
208
class build_ext_if_possible(build_ext):
194
220
    def run(self):
195
221
        try:
196
222
            build_ext.run(self)
197
 
        except DistutilsPlatformError, e:
 
223
        except DistutilsPlatformError:
 
224
            e = sys.exc_info()[1]
198
225
            if not self.allow_python_fallback:
199
226
                log.warn('\n  Cannot build extensions.\n'
200
227
                         '  Use "build_ext --allow-python-fallback" to use'
242
269
    c_name = path + '.c'
243
270
    define_macros = []
244
271
    if sys.platform == 'win32':
245
 
        # pyrex uses the macro WIN32 to detect the platform, even though it should
246
 
        # be using something like _WIN32 or MS_WINDOWS, oh well, we can give it the
247
 
        # right value.
 
272
        # pyrex uses the macro WIN32 to detect the platform, even though it
 
273
        # should be using something like _WIN32 or MS_WINDOWS, oh well, we can
 
274
        # give it the right value.
248
275
        define_macros.append(('WIN32', None))
249
276
    if have_pyrex:
250
277
        source = [pyrex_name]
259
286
        define_macros=define_macros, libraries=libraries))
260
287
 
261
288
 
262
 
add_pyrex_extension('bzrlib._btree_serializer_c')
 
289
add_pyrex_extension('bzrlib._annotator_pyx')
 
290
add_pyrex_extension('bzrlib._bencode_pyx')
 
291
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
263
292
add_pyrex_extension('bzrlib._groupcompress_pyx',
264
293
                    extra_source=['bzrlib/diff-delta.c'])
265
 
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
266
 
add_pyrex_extension('bzrlib._knit_load_data_c')
267
 
add_pyrex_extension('bzrlib._chk_map_pyx', libraries=['z'])
 
294
add_pyrex_extension('bzrlib._knit_load_data_pyx')
 
295
add_pyrex_extension('bzrlib._known_graph_pyx')
 
296
add_pyrex_extension('bzrlib._rio_pyx')
268
297
if sys.platform == 'win32':
269
 
    add_pyrex_extension('bzrlib._dirstate_helpers_c',
 
298
    add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
270
299
                        libraries=['Ws2_32'])
271
300
    add_pyrex_extension('bzrlib._walkdirs_win32')
272
301
else:
273
 
    if have_pyrex and pyrex_version == '0.9.4.1':
 
302
    if have_pyrex and pyrex_version_info[:3] == (0,9,4):
274
303
        # Pyrex 0.9.4.1 fails to compile this extension correctly
275
304
        # The code it generates re-uses a "local" pointer and
276
305
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
277
306
        # which is NULL safe with PY_DECREF which is not.)
278
 
        print 'Cannot build extension "bzrlib._dirstate_helpers_c" using'
279
 
        print 'your version of pyrex "%s". Please upgrade your pyrex' % (
280
 
            pyrex_version,)
281
 
        print 'install. For now, the non-compiled (python) version will'
282
 
        print 'be used instead.'
 
307
        # <https://bugs.launchpad.net/bzr/+bug/449372>
 
308
        # <https://bugs.launchpad.net/bzr/+bug/276868>
 
309
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
 
310
        print('your version of pyrex "%s". Please upgrade your pyrex'
 
311
              % (pyrex_version,))
 
312
        print('install. For now, the non-compiled (python) version will')
 
313
        print('be used instead.')
283
314
    else:
284
 
        add_pyrex_extension('bzrlib._dirstate_helpers_c')
 
315
        add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
285
316
    add_pyrex_extension('bzrlib._readdir_pyx')
286
 
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
 
317
add_pyrex_extension('bzrlib._chk_map_pyx')
 
318
ext_modules.append(Extension('bzrlib._patiencediff_c',
 
319
                             ['bzrlib/_patiencediff_c.c']))
 
320
if have_pyrex and pyrex_version_info < (0, 9, 6, 3):
 
321
    print("")
 
322
    print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
 
323
        pyrex_version))
 
324
    print('and static_tuple extensions.')
 
325
    print('Please upgrade to at least Pyrex 0.9.6.3')
 
326
    print("")
 
327
    # TODO: Should this be a fatal error?
 
328
else:
 
329
    # We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
 
330
    # on simple_set
 
331
    add_pyrex_extension('bzrlib._simple_set_pyx')
 
332
    ext_modules.append(Extension('bzrlib._static_tuple_c',
 
333
                                 ['bzrlib/_static_tuple_c.c']))
 
334
add_pyrex_extension('bzrlib._btree_serializer_pyx')
287
335
 
288
336
 
289
337
if unavailable_files:
290
 
    print 'C extension(s) not found:'
291
 
    print '   %s' % ('\n  '.join(unavailable_files),)
292
 
    print 'The python versions will be used instead.'
293
 
    print
 
338
    print('C extension(s) not found:')
 
339
    print('   %s' % ('\n  '.join(unavailable_files),))
 
340
    print('The python versions will be used instead.')
 
341
    print("")
294
342
 
295
343
 
296
344
def get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
316
364
    # Ensure tbzrlib itself is on sys.path
317
365
    sys.path.append(tbzr_root)
318
366
 
319
 
    # Ensure our COM "entry-point" is on sys.path
320
 
    sys.path.append(os.path.join(tbzr_root, "shellext", "python"))
321
 
 
322
367
    packages.append("tbzrlib")
323
368
 
324
369
    # collect up our icons.
346
391
    excludes.extend("""pywin pywin.dialogs pywin.dialogs.list
347
392
                       win32ui crawler.Crawler""".split())
348
393
 
349
 
    # NOTE: We still create a DLL version of the Python implemented shell
350
 
    # extension for testing purposes - but it is *not* registered by
351
 
    # default - our C++ one is instead.  To discourage people thinking
352
 
    # this DLL is still necessary, its called 'tbzr_old.dll'
353
 
    tbzr = dict(
354
 
        modules=["tbzr"],
355
 
        create_exe = False, # we only want a .dll
356
 
        dest_base = 'tbzr_old',
357
 
    )
358
 
    com_targets.append(tbzr)
359
 
 
360
394
    # tbzrcache executables - a "console" version for debugging and a
361
395
    # GUI version that is generally used.
362
396
    tbzrcache = dict(
374
408
    # ditto for the tbzrcommand tool
375
409
    tbzrcommand = dict(
376
410
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
377
 
        icon_resources = [(0,'bzr.ico')],
 
411
        icon_resources = icon_resources,
 
412
        other_resources = other_resources,
378
413
    )
379
414
    console_targets.append(tbzrcommand)
380
415
    tbzrcommandw = tbzrcommand.copy()
387
422
    console_targets.append(tracer)
388
423
 
389
424
    # The C++ implemented shell extensions.
390
 
    dist_dir = os.path.join(tbzr_root, "shellext", "cpp", "tbzrshellext",
391
 
                            "build", "dist")
 
425
    dist_dir = os.path.join(tbzr_root, "shellext", "build")
392
426
    data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x86.dll')]))
393
427
    data_files.append(('', [os.path.join(dist_dir, 'tbzrshellext_x64.dll')]))
394
428
 
395
429
 
396
 
def get_qbzr_py2exe_info(includes, excludes, packages):
 
430
def get_qbzr_py2exe_info(includes, excludes, packages, data_files):
397
431
    # PyQt4 itself still escapes the plugin detection code for some reason...
398
 
    packages.append('PyQt4')
399
 
    excludes.append('PyQt4.elementtree.ElementTree')
 
432
    includes.append('PyQt4.QtCore')
 
433
    includes.append('PyQt4.QtGui')
 
434
    includes.append('PyQt4.QtTest')
400
435
    includes.append('sip') # extension module required for Qt.
401
436
    packages.append('pygments') # colorizer for qbzr
402
437
    packages.append('docutils') # html formatting
403
 
    # but we can avoid many Qt4 Dlls.
404
 
    dll_excludes.extend(
405
 
        """QtAssistantClient4.dll QtCLucene4.dll QtDesigner4.dll
406
 
        QtHelp4.dll QtNetwork4.dll QtOpenGL4.dll QtScript4.dll
407
 
        QtSql4.dll QtTest4.dll QtWebKit4.dll QtXml4.dll
408
 
        qscintilla2.dll""".split())
 
438
    includes.append('win32event')  # for qsubprocess stuff
409
439
    # the qt binaries might not be on PATH...
410
 
    qt_dir = os.path.join(sys.prefix, "PyQt4", "bin")
411
 
    path = os.environ.get("PATH","")
412
 
    if qt_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
413
 
        os.environ["PATH"] = path + os.pathsep + qt_dir
 
440
    # They seem to install to a place like C:\Python25\PyQt4\*
 
441
    # Which is not the same as C:\Python25\Lib\site-packages\PyQt4
 
442
    pyqt_dir = os.path.join(sys.prefix, "PyQt4")
 
443
    pyqt_bin_dir = os.path.join(pyqt_dir, "bin")
 
444
    if os.path.isdir(pyqt_bin_dir):
 
445
        path = os.environ.get("PATH", "")
 
446
        if pyqt_bin_dir.lower() not in [p.lower() for p in path.split(os.pathsep)]:
 
447
            os.environ["PATH"] = path + os.pathsep + pyqt_bin_dir
 
448
    # also add all imageformat plugins to distribution
 
449
    # We will look in 2 places, dirname(PyQt4.__file__) and pyqt_dir
 
450
    base_dirs_to_check = []
 
451
    if os.path.isdir(pyqt_dir):
 
452
        base_dirs_to_check.append(pyqt_dir)
 
453
    try:
 
454
        import PyQt4
 
455
    except ImportError:
 
456
        pass
 
457
    else:
 
458
        pyqt4_base_dir = os.path.dirname(PyQt4.__file__)
 
459
        if pyqt4_base_dir != pyqt_dir:
 
460
            base_dirs_to_check.append(pyqt4_base_dir)
 
461
    if not base_dirs_to_check:
 
462
        log.warn("Can't find PyQt4 installation -> not including imageformat"
 
463
                 " plugins")
 
464
    else:
 
465
        files = []
 
466
        for base_dir in base_dirs_to_check:
 
467
            plug_dir = os.path.join(base_dir, 'plugins', 'imageformats')
 
468
            if os.path.isdir(plug_dir):
 
469
                for fname in os.listdir(plug_dir):
 
470
                    # Include plugin dlls, but not debugging dlls
 
471
                    fullpath = os.path.join(plug_dir, fname)
 
472
                    if fname.endswith('.dll') and not fname.endswith('d4.dll'):
 
473
                        files.append(fullpath)
 
474
        if files:
 
475
            data_files.append(('imageformats', files))
 
476
        else:
 
477
            log.warn('PyQt4 was found, but we could not find any imageformat'
 
478
                     ' plugins. Are you sure your configuration is correct?')
414
479
 
415
480
 
416
481
def get_svn_py2exe_info(includes, excludes, packages):
417
482
    packages.append('subvertpy')
 
483
    packages.append('sqlite3')
 
484
 
 
485
 
 
486
def get_git_py2exe_info(includes, excludes, packages):
 
487
    packages.append('dulwich')
 
488
 
 
489
 
 
490
def get_fastimport_py2exe_info(includes, excludes, packages):
 
491
    # This is the python-fastimport package, not to be confused with the
 
492
    # bzr-fastimport plugin.
 
493
    packages.append('fastimport')
418
494
 
419
495
 
420
496
if 'bdist_wininst' in sys.argv:
441
517
            # help pages
442
518
            'data_files': find_docs(),
443
519
            # for building pyrex extensions
444
 
            'cmdclass': {'build_ext': build_ext_if_possible},
 
520
            'cmdclass': command_classes,
445
521
           }
446
522
 
447
523
    ARGS.update(META_INFO)
448
524
    ARGS.update(BZRLIB)
 
525
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
449
526
    ARGS.update(PKG_DATA)
450
 
    
 
527
 
451
528
    setup(**ARGS)
452
529
 
453
530
elif 'py2exe' in sys.argv:
454
 
    import glob
455
531
    # py2exe setup
456
532
    import py2exe
457
533
 
478
554
            install_data.run(self)
479
555
 
480
556
            py2exe = self.distribution.get_command_obj('py2exe', False)
481
 
            optimize = py2exe.optimize
 
557
            # GZ 2010-04-19: Setup has py2exe.optimize as 2, but give plugins
 
558
            #                time before living with docstring stripping
 
559
            optimize = 1
482
560
            compile_names = [f for f in self.outfiles if f.endswith('.py')]
 
561
            # Round mtime to nearest even second so that installing on a FAT
 
562
            # filesystem bytecode internal and script timestamps will match
 
563
            for f in compile_names:
 
564
                mtime = os.stat(f).st_mtime
 
565
                remainder = mtime % 2
 
566
                if remainder:
 
567
                    mtime -= remainder
 
568
                    os.utime(f, (mtime, mtime))
483
569
            byte_compile(compile_names,
484
570
                         optimize=optimize,
485
571
                         force=self.force, prefix=self.install_dir,
486
572
                         dry_run=self.dry_run)
487
 
            if optimize:
488
 
                suffix = 'o'
489
 
            else:
490
 
                suffix = 'c'
491
 
            self.outfiles.extend([f + suffix for f in compile_names])
 
573
            self.outfiles.extend([f + 'o' for f in compile_names])
492
574
    # end of class install_data_with_bytecompile
493
575
 
494
576
    target = py2exe.build_exe.Target(script = "bzr",
498
580
                                     version = version_str,
499
581
                                     description = META_INFO['description'],
500
582
                                     author = META_INFO['author'],
501
 
                                     copyright = "(c) Canonical Ltd, 2005-2007",
 
583
                                     copyright = "(c) Canonical Ltd, 2005-2010",
502
584
                                     company_name = "Canonical Ltd.",
503
585
                                     comments = META_INFO['description'],
504
586
                                    )
 
587
    gui_target = copy.copy(target)
 
588
    gui_target.dest_base = "bzrw"
505
589
 
506
590
    packages = BZRLIB['packages']
507
591
    packages.remove('bzrlib')
517
601
    if sys.version.startswith('2.4'):
518
602
        # adding elementtree package
519
603
        additional_packages.add('elementtree')
520
 
    elif sys.version.startswith('2.5'):
 
604
    elif sys.version.startswith('2.6') or sys.version.startswith('2.5'):
521
605
        additional_packages.add('xml.etree')
522
606
    else:
523
607
        import warnings
531
615
                  ImaginaryModule cElementTree elementtree.ElementTree
532
616
                  Crypto.PublicKey._fastmath
533
617
                  medusa medusa.filesys medusa.ftp_server
534
 
                  tools tools.doc_generate
 
618
                  tools
535
619
                  resource validate""".split()
536
620
    dll_excludes = []
537
621
 
569
653
            excludes.extend(["bzrlib.plugins." + d for d in dirs])
570
654
        x = []
571
655
        for i in files:
572
 
            if os.path.splitext(i)[1] not in [".py", ".pyd", ".dll", ".mo"]:
 
656
            # Throw away files we don't want packaged. Note that plugins may
 
657
            # have data files with all sorts of extensions so we need to
 
658
            # be conservative here about what we ditch.
 
659
            ext = os.path.splitext(i)[1]
 
660
            if ext.endswith('~') or ext in [".pyc", ".swp"]:
573
661
                continue
574
662
            if i == '__init__.py' and root == 'bzrlib/plugins':
575
663
                continue
588
676
    console_targets = [target,
589
677
                       'tools/win32/bzr_postinstall.py',
590
678
                       ]
591
 
    gui_targets = []
592
 
    com_targets = []
593
 
    data_files = topics_files + plugins_files
 
679
    gui_targets = [gui_target]
 
680
    data_files = topics_files + plugins_files + I18N_FILES
594
681
 
595
682
    if 'qbzr' in plugins:
596
 
        get_qbzr_py2exe_info(includes, excludes, packages)
 
683
        get_qbzr_py2exe_info(includes, excludes, packages, data_files)
597
684
 
598
685
    if 'svn' in plugins:
599
686
        get_svn_py2exe_info(includes, excludes, packages)
600
687
 
 
688
    if 'git' in plugins:
 
689
        get_git_py2exe_info(includes, excludes, packages)
 
690
 
 
691
    if 'fastimport' in plugins:
 
692
        get_fastimport_py2exe_info(includes, excludes, packages)
 
693
 
601
694
    if "TBZR" in os.environ:
602
695
        # TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
603
696
        # TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
604
697
        # can be downloaded from (username=guest, blank password):
605
 
        # http://tortoisesvn.tigris.org/svn/tortoisesvn/TortoiseOverlays/version-1.0.4/bin/TortoiseOverlays-1.0.4.11886-win32.msi
 
698
        # http://tortoisesvn.tigris.org/svn/tortoisesvn/TortoiseOverlays
 
699
        # look for: version-1.0.4/bin/TortoiseOverlays-1.0.4.11886-win32.msi
606
700
        # Ditto for TORTOISE_OVERLAYS_MSI_X64, pointing at *-x64.msi.
607
701
        for needed in ('TORTOISE_OVERLAYS_MSI_WIN32',
608
702
                       'TORTOISE_OVERLAYS_MSI_X64'):
 
703
            url = ('http://guest:@tortoisesvn.tigris.org/svn/tortoisesvn'
 
704
                   '/TortoiseOverlays')
609
705
            if not os.path.isfile(os.environ.get(needed, '<nofile>')):
610
 
                raise RuntimeError("Please set %s to the"
611
 
                                   " location of the relevant TortoiseOverlays"
612
 
                                   " .msi installer file" % needed)
 
706
                raise RuntimeError(
 
707
                    "\nPlease set %s to the location of the relevant"
 
708
                    "\nTortoiseOverlays .msi installer file."
 
709
                    " The installers can be found at"
 
710
                    "\n  %s"
 
711
                    "\ncheck in the version-X.Y.Z/bin/ subdir" % (needed, url))
613
712
        get_tbzr_py2exe_info(includes, excludes, packages, console_targets,
614
713
                             gui_targets, data_files)
615
714
    else:
616
715
        # print this warning to stderr as output is redirected, so it is seen
617
716
        # at build time.  Also to stdout so it appears in the log
618
717
        for f in (sys.stderr, sys.stdout):
619
 
            print >> f, \
620
 
                "Skipping TBZR binaries - please set TBZR to a directory to enable"
 
718
            f.write("Skipping TBZR binaries - "
 
719
                "please set TBZR to a directory to enable\n")
621
720
 
622
721
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
623
722
    # in on Vista.
624
 
    dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
 
723
    dll_excludes.extend(["MSWSOCK.dll",
 
724
                         "MSVCP60.dll",
 
725
                         "MSVCP90.dll",
 
726
                         "powrprof.dll",
 
727
                         "SHFOLDER.dll"])
625
728
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
626
729
                               "includes": includes,
627
730
                               "excludes": excludes,
628
731
                               "dll_excludes": dll_excludes,
629
732
                               "dist_dir": "win32_bzr.exe",
630
 
                               "optimize": 1,
 
733
                               "optimize": 2,
 
734
                               "custom_boot_script":
 
735
                                        "tools/win32/py2exe_boot_common.py",
631
736
                              },
632
737
                   }
633
738
 
634
 
    setup(options=options_list,
635
 
          console=console_targets,
636
 
          windows=gui_targets,
637
 
          com_server=com_targets,
638
 
          zipfile='lib/library.zip',
639
 
          data_files=data_files,
640
 
          cmdclass={'install_data': install_data_with_bytecompile},
641
 
          )
 
739
    # We want the libaray.zip to have optimize = 2, but the exe to have
 
740
    # optimize = 1, so that .py files that get compilied at run time
 
741
    # (e.g. user installed plugins) dont have their doc strings removed.
 
742
    class py2exe_no_oo_exe(py2exe.build_exe.py2exe):
 
743
        def build_executable(self, *args, **kwargs):
 
744
            self.optimize = 1
 
745
            py2exe.build_exe.py2exe.build_executable(self, *args, **kwargs)
 
746
            self.optimize = 2
 
747
 
 
748
    if __name__ == '__main__':
 
749
        command_classes['install_data'] = install_data_with_bytecompile
 
750
        command_classes['py2exe'] = py2exe_no_oo_exe
 
751
        setup(options=options_list,
 
752
              console=console_targets,
 
753
              windows=gui_targets,
 
754
              zipfile='lib/library.zip',
 
755
              data_files=data_files,
 
756
              cmdclass=command_classes,
 
757
              )
642
758
 
643
759
else:
644
760
    # ad-hoc for easy_install
645
761
    DATA_FILES = []
646
762
    if not 'bdist_egg' in sys.argv:
647
 
        # generate and install bzr.1 only with plain install, not easy_install one
 
763
        # generate and install bzr.1 only with plain install, not the
 
764
        # easy_install one
648
765
        DATA_FILES = [('man/man1', ['bzr.1'])]
649
766
 
 
767
    DATA_FILES = DATA_FILES + I18N_FILES
650
768
    # std setup
651
769
    ARGS = {'scripts': ['bzr'],
652
770
            'data_files': DATA_FILES,
658
776
    ARGS.update(BZRLIB)
659
777
    ARGS.update(PKG_DATA)
660
778
 
661
 
    setup(**ARGS)
 
779
    if __name__ == '__main__':
 
780
        setup(**ARGS)