~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
import os.path
11
11
import sys
12
12
import copy
 
13
import glob
13
14
 
14
 
if sys.version_info < (2, 4):
15
 
    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")
16
17
    sys.exit(1)
17
18
 
18
19
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
69
70
                                        'tests/ssl_certs/ca.crt',
70
71
                                        'tests/ssl_certs/server_without_pass.key',
71
72
                                        'tests/ssl_certs/server_with_pass.key',
72
 
                                        'tests/ssl_certs/server.crt'
 
73
                                        'tests/ssl_certs/server.crt',
73
74
                                       ]},
74
75
           }
75
 
 
 
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]))
76
81
 
77
82
def get_bzrlib_packages():
78
83
    """Recurse through the bzrlib directory, and extract the package names"""
152
157
    Generate bzr.1.
153
158
    """
154
159
 
 
160
    sub_commands = build.sub_commands + [
 
161
            ('build_mo', lambda _: True),
 
162
            ]
 
163
 
155
164
    def run(self):
156
165
        build.run(self)
157
166
 
163
172
## Setup
164
173
########################
165
174
 
 
175
from bzrlib.bzr_distutils import build_mo
 
176
 
166
177
command_classes = {'install_scripts': my_install_scripts,
167
 
                   'build': bzr_build}
 
178
                   'build': bzr_build,
 
179
                   'build_mo': build_mo,
 
180
                   }
168
181
from distutils import log
169
182
from distutils.errors import CCompilerError, DistutilsPlatformError
170
183
from distutils.extension import Extension
171
184
ext_modules = []
172
185
try:
173
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...")
174
191
        from Pyrex.Distutils import build_ext
175
192
        from Pyrex.Compiler.Version import version as pyrex_version
176
 
    except ImportError:
177
 
        print("No Pyrex, trying Cython...")
178
 
        from Cython.Distutils import build_ext
179
 
        from Cython.Compiler.Version import version as pyrex_version
180
193
except ImportError:
181
194
    have_pyrex = False
182
195
    # try to build the extension from the prior generated source.
189
202
    from distutils.command.build_ext import build_ext
190
203
else:
191
204
    have_pyrex = True
192
 
    pyrex_version_info = tuple(map(int, pyrex_version.split('.')))
 
205
    pyrex_version_info = tuple(map(int, pyrex_version.rstrip("+").split('.')))
193
206
 
194
207
 
195
208
class build_ext_if_possible(build_ext):
291
304
        # The code it generates re-uses a "local" pointer and
292
305
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
293
306
        # which is NULL safe with PY_DECREF which is not.)
294
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/449372>
295
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/276868>
 
307
        # <https://bugs.launchpad.net/bzr/+bug/449372>
 
308
        # <https://bugs.launchpad.net/bzr/+bug/276868>
296
309
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
297
 
        print('your version of pyrex "%s". Please upgrade your pyrex' % (
298
 
            pyrex_version,))
 
310
        print('your version of pyrex "%s". Please upgrade your pyrex'
 
311
              % (pyrex_version,))
299
312
        print('install. For now, the non-compiled (python) version will')
300
313
        print('be used instead.')
301
314
    else:
395
408
    # ditto for the tbzrcommand tool
396
409
    tbzrcommand = dict(
397
410
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
398
 
        icon_resources = [(0,'bzr.ico')],
 
411
        icon_resources = icon_resources,
 
412
        other_resources = other_resources,
399
413
    )
400
414
    console_targets.append(tbzrcommand)
401
415
    tbzrcommandw = tbzrcommand.copy()
468
482
    packages.append('sqlite3')
469
483
 
470
484
 
 
485
def get_git_py2exe_info(includes, excludes, packages):
 
486
    packages.append('dulwich')
 
487
 
 
488
 
 
489
def get_fastimport_py2exe_info(includes, excludes, packages):
 
490
    # This is the python-fastimport package, not to be confused with the
 
491
    # bzr-fastimport plugin.
 
492
    packages.append('fastimport')
 
493
 
 
494
 
471
495
if 'bdist_wininst' in sys.argv:
472
496
    def find_docs():
473
497
        docs = []
492
516
            # help pages
493
517
            'data_files': find_docs(),
494
518
            # for building pyrex extensions
495
 
            'cmdclass': {'build_ext': build_ext_if_possible},
 
519
            'cmdclass': command_classes,
496
520
           }
497
521
 
498
522
    ARGS.update(META_INFO)
499
523
    ARGS.update(BZRLIB)
 
524
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
500
525
    ARGS.update(PKG_DATA)
501
 
    
 
526
 
502
527
    setup(**ARGS)
503
528
 
504
529
elif 'py2exe' in sys.argv:
505
 
    import glob
506
530
    # py2exe setup
507
531
    import py2exe
508
532
 
652
676
                       'tools/win32/bzr_postinstall.py',
653
677
                       ]
654
678
    gui_targets = [gui_target]
655
 
    data_files = topics_files + plugins_files
 
679
    data_files = topics_files + plugins_files + I18N_FILES
656
680
 
657
681
    if 'qbzr' in plugins:
658
682
        get_qbzr_py2exe_info(includes, excludes, packages, data_files)
660
684
    if 'svn' in plugins:
661
685
        get_svn_py2exe_info(includes, excludes, packages)
662
686
 
 
687
    if 'git' in plugins:
 
688
        get_git_py2exe_info(includes, excludes, packages)
 
689
 
 
690
    if 'fastimport' in plugins:
 
691
        get_fastimport_py2exe_info(includes, excludes, packages)
 
692
 
663
693
    if "TBZR" in os.environ:
664
694
        # TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
665
695
        # TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
689
719
 
690
720
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
691
721
    # in on Vista.
692
 
    dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
 
722
    dll_excludes.extend(["MSWSOCK.dll",
 
723
                         "MSVCP60.dll",
 
724
                         "MSVCP90.dll",
 
725
                         "powrprof.dll",
 
726
                         "SHFOLDER.dll"])
693
727
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
694
728
                               "includes": includes,
695
729
                               "excludes": excludes,
711
745
            self.optimize = 2
712
746
 
713
747
    if __name__ == '__main__':
 
748
        command_classes['install_data'] = install_data_with_bytecompile
 
749
        command_classes['py2exe'] = py2exe_no_oo_exe
714
750
        setup(options=options_list,
715
751
              console=console_targets,
716
752
              windows=gui_targets,
717
753
              zipfile='lib/library.zip',
718
754
              data_files=data_files,
719
 
              cmdclass={'install_data': install_data_with_bytecompile,
720
 
                        'py2exe': py2exe_no_oo_exe},
 
755
              cmdclass=command_classes,
721
756
              )
722
757
 
723
758
else:
728
763
        # easy_install one
729
764
        DATA_FILES = [('man/man1', ['bzr.1'])]
730
765
 
 
766
    DATA_FILES = DATA_FILES + I18N_FILES
731
767
    # std setup
732
768
    ARGS = {'scripts': ['bzr'],
733
769
            'data_files': DATA_FILES,