~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

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
66
67
            'package_data': {'bzrlib': ['doc/api/*.txt',
67
68
                                        'tests/test_patches_data/*',
68
69
                                        'help_topics/en/*.txt',
 
70
                                        'tests/ssl_certs/ca.crt',
69
71
                                        'tests/ssl_certs/server_without_pass.key',
70
72
                                        'tests/ssl_certs/server_with_pass.key',
71
 
                                        'tests/ssl_certs/server.crt'
 
73
                                        'tests/ssl_certs/server.crt',
72
74
                                       ]},
73
75
           }
74
 
 
 
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]))
75
81
 
76
82
def get_bzrlib_packages():
77
83
    """Recurse through the bzrlib directory, and extract the package names"""
151
157
    Generate bzr.1.
152
158
    """
153
159
 
 
160
    sub_commands = build.sub_commands + [
 
161
            ('build_mo', lambda _: True),
 
162
            ]
 
163
 
154
164
    def run(self):
155
165
        build.run(self)
156
166
 
162
172
## Setup
163
173
########################
164
174
 
 
175
from bzrlib.bzr_distutils import build_mo
 
176
 
165
177
command_classes = {'install_scripts': my_install_scripts,
166
 
                   'build': bzr_build}
 
178
                   'build': bzr_build,
 
179
                   'build_mo': build_mo,
 
180
                   }
167
181
from distutils import log
168
182
from distutils.errors import CCompilerError, DistutilsPlatformError
169
183
from distutils.extension import Extension
170
184
ext_modules = []
171
185
try:
172
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...")
173
191
        from Pyrex.Distutils import build_ext
174
192
        from Pyrex.Compiler.Version import version as pyrex_version
175
 
    except ImportError:
176
 
        print("No Pyrex, trying Cython...")
177
 
        from Cython.Distutils import build_ext
178
 
        from Cython.Compiler.Version import version as pyrex_version
179
193
except ImportError:
180
194
    have_pyrex = False
181
195
    # try to build the extension from the prior generated source.
188
202
    from distutils.command.build_ext import build_ext
189
203
else:
190
204
    have_pyrex = True
191
 
    pyrex_version_info = tuple(map(int, pyrex_version.split('.')))
 
205
    pyrex_version_info = tuple(map(int, pyrex_version.rstrip("+").split('.')))
192
206
 
193
207
 
194
208
class build_ext_if_possible(build_ext):
290
304
        # The code it generates re-uses a "local" pointer and
291
305
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
292
306
        # which is NULL safe with PY_DECREF which is not.)
293
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/449372>
294
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/276868>
 
307
        # <https://bugs.launchpad.net/bzr/+bug/449372>
 
308
        # <https://bugs.launchpad.net/bzr/+bug/276868>
295
309
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
296
 
        print('your version of pyrex "%s". Please upgrade your pyrex' % (
297
 
            pyrex_version,))
 
310
        print('your version of pyrex "%s". Please upgrade your pyrex'
 
311
              % (pyrex_version,))
298
312
        print('install. For now, the non-compiled (python) version will')
299
313
        print('be used instead.')
300
314
    else:
394
408
    # ditto for the tbzrcommand tool
395
409
    tbzrcommand = dict(
396
410
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
397
 
        icon_resources = [(0,'bzr.ico')],
 
411
        icon_resources = icon_resources,
 
412
        other_resources = other_resources,
398
413
    )
399
414
    console_targets.append(tbzrcommand)
400
415
    tbzrcommandw = tbzrcommand.copy()
416
431
    # PyQt4 itself still escapes the plugin detection code for some reason...
417
432
    includes.append('PyQt4.QtCore')
418
433
    includes.append('PyQt4.QtGui')
 
434
    includes.append('PyQt4.QtTest')
419
435
    includes.append('sip') # extension module required for Qt.
420
436
    packages.append('pygments') # colorizer for qbzr
421
437
    packages.append('docutils') # html formatting
467
483
    packages.append('sqlite3')
468
484
 
469
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')
 
494
 
 
495
 
470
496
if 'bdist_wininst' in sys.argv:
471
497
    def find_docs():
472
498
        docs = []
491
517
            # help pages
492
518
            'data_files': find_docs(),
493
519
            # for building pyrex extensions
494
 
            'cmdclass': {'build_ext': build_ext_if_possible},
 
520
            'cmdclass': command_classes,
495
521
           }
496
522
 
497
523
    ARGS.update(META_INFO)
498
524
    ARGS.update(BZRLIB)
 
525
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
499
526
    ARGS.update(PKG_DATA)
500
 
    
 
527
 
501
528
    setup(**ARGS)
502
529
 
503
530
elif 'py2exe' in sys.argv:
504
 
    import glob
505
531
    # py2exe setup
506
532
    import py2exe
507
533
 
651
677
                       'tools/win32/bzr_postinstall.py',
652
678
                       ]
653
679
    gui_targets = [gui_target]
654
 
    data_files = topics_files + plugins_files
 
680
    data_files = topics_files + plugins_files + I18N_FILES
655
681
 
656
682
    if 'qbzr' in plugins:
657
683
        get_qbzr_py2exe_info(includes, excludes, packages, data_files)
659
685
    if 'svn' in plugins:
660
686
        get_svn_py2exe_info(includes, excludes, packages)
661
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
 
662
694
    if "TBZR" in os.environ:
663
695
        # TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
664
696
        # TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
688
720
 
689
721
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
690
722
    # in on Vista.
691
 
    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"])
692
728
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
693
729
                               "includes": includes,
694
730
                               "excludes": excludes,
710
746
            self.optimize = 2
711
747
 
712
748
    if __name__ == '__main__':
 
749
        command_classes['install_data'] = install_data_with_bytecompile
 
750
        command_classes['py2exe'] = py2exe_no_oo_exe
713
751
        setup(options=options_list,
714
752
              console=console_targets,
715
753
              windows=gui_targets,
716
754
              zipfile='lib/library.zip',
717
755
              data_files=data_files,
718
 
              cmdclass={'install_data': install_data_with_bytecompile,
719
 
                        'py2exe': py2exe_no_oo_exe},
 
756
              cmdclass=command_classes,
720
757
              )
721
758
 
722
759
else:
727
764
        # easy_install one
728
765
        DATA_FILES = [('man/man1', ['bzr.1'])]
729
766
 
730
 
    if sys.platform != 'win32':
731
 
        # see https://wiki.kubuntu.org/Apport/DeveloperHowTo
732
 
        #
733
 
        # checking the paths and hardcoding the check for root is a bit gross,
734
 
        # but I don't see a cleaner way to find out the locations in a way
735
 
        # that's going to align with the hardcoded paths in apport.
736
 
        if os.geteuid() == 0:
737
 
            DATA_FILES += [
738
 
                ('/usr/share/apport/package-hooks',
739
 
                    ['apport/source_bzr.py']),
740
 
                ('/etc/apport/crashdb.conf.d/',
741
 
                    ['apport/bzr-crashdb.conf']),]
742
 
 
 
767
    DATA_FILES = DATA_FILES + I18N_FILES
743
768
    # std setup
744
769
    ARGS = {'scripts': ['bzr'],
745
770
            'data_files': DATA_FILES,