~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-13 06:14:37 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101013061437-2e2m9gro1eusnbb8
Tweaks to the sphinx build.

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