~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Martin Pool
  • Date: 2010-08-18 07:25:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5383.
  • Revision ID: mbp@sourcefrog.net-20100818072522-uk3gsazoia3l3s0a
Start adding 'what's new in 2.3'

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
import sys
12
12
import copy
13
13
 
14
 
if sys.version_info < (2, 6):
15
 
    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")
16
16
    sys.exit(1)
17
17
 
18
18
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
66
66
            'package_data': {'bzrlib': ['doc/api/*.txt',
67
67
                                        'tests/test_patches_data/*',
68
68
                                        'help_topics/en/*.txt',
69
 
                                        'tests/ssl_certs/ca.crt',
70
69
                                        'tests/ssl_certs/server_without_pass.key',
71
70
                                        'tests/ssl_certs/server_with_pass.key',
72
 
                                        'tests/ssl_certs/server.crt',
73
 
                                        'locale/*/LC_MESSAGES/*.mo',
 
71
                                        'tests/ssl_certs/server.crt'
74
72
                                       ]},
75
73
           }
76
74
 
153
151
    Generate bzr.1.
154
152
    """
155
153
 
156
 
    sub_commands = build.sub_commands + [
157
 
            ('build_mo', lambda _: True),
158
 
            ]
159
 
 
160
154
    def run(self):
161
155
        build.run(self)
162
156
 
168
162
## Setup
169
163
########################
170
164
 
171
 
from tools.build_mo import build_mo
172
 
 
173
165
command_classes = {'install_scripts': my_install_scripts,
174
 
                   'build': bzr_build,
175
 
                   'build_mo': build_mo,
176
 
                   }
 
166
                   'build': bzr_build}
177
167
from distutils import log
178
168
from distutils.errors import CCompilerError, DistutilsPlatformError
179
169
from distutils.extension import Extension
180
170
ext_modules = []
181
171
try:
182
172
    try:
 
173
        from Pyrex.Distutils import build_ext
 
174
        from Pyrex.Compiler.Version import version as pyrex_version
 
175
    except ImportError:
 
176
        print("No Pyrex, trying Cython...")
183
177
        from Cython.Distutils import build_ext
184
178
        from Cython.Compiler.Version import version as pyrex_version
185
 
    except ImportError:
186
 
        print("No Cython, trying Pyrex...")
187
 
        from Pyrex.Distutils import build_ext
188
 
        from Pyrex.Compiler.Version import version as pyrex_version
189
179
except ImportError:
190
180
    have_pyrex = False
191
181
    # try to build the extension from the prior generated source.
300
290
        # The code it generates re-uses a "local" pointer and
301
291
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
302
292
        # which is NULL safe with PY_DECREF which is not.)
303
 
        # <https://bugs.launchpad.net/bzr/+bug/449372>
304
 
        # <https://bugs.launchpad.net/bzr/+bug/276868>
 
293
        # <https://bugs.edge.launchpad.net/bzr/+bug/449372>
 
294
        # <https://bugs.edge.launchpad.net/bzr/+bug/276868>
305
295
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
306
 
        print('your version of pyrex "%s". Please upgrade your pyrex'
307
 
              % (pyrex_version,))
 
296
        print('your version of pyrex "%s". Please upgrade your pyrex' % (
 
297
            pyrex_version,))
308
298
        print('install. For now, the non-compiled (python) version will')
309
299
        print('be used instead.')
310
300
    else:
404
394
    # ditto for the tbzrcommand tool
405
395
    tbzrcommand = dict(
406
396
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
407
 
        icon_resources = icon_resources,
408
 
        other_resources = other_resources,
 
397
        icon_resources = [(0,'bzr.ico')],
409
398
    )
410
399
    console_targets.append(tbzrcommand)
411
400
    tbzrcommandw = tbzrcommand.copy()
478
467
    packages.append('sqlite3')
479
468
 
480
469
 
481
 
def get_fastimport_py2exe_info(includes, excludes, packages):
482
 
    # This is the python-fastimport package, not to be confused with the
483
 
    # bzr-fastimport plugin.
484
 
    packages.append('fastimport')
485
 
 
486
 
 
487
470
if 'bdist_wininst' in sys.argv:
488
471
    def find_docs():
489
472
        docs = []
508
491
            # help pages
509
492
            'data_files': find_docs(),
510
493
            # for building pyrex extensions
511
 
            'cmdclass': command_classes,
 
494
            'cmdclass': {'build_ext': build_ext_if_possible},
512
495
           }
513
496
 
514
497
    ARGS.update(META_INFO)
515
498
    ARGS.update(BZRLIB)
516
499
    ARGS.update(PKG_DATA)
517
 
 
 
500
    
518
501
    setup(**ARGS)
519
502
 
520
503
elif 'py2exe' in sys.argv:
676
659
    if 'svn' in plugins:
677
660
        get_svn_py2exe_info(includes, excludes, packages)
678
661
 
679
 
    if 'fastimport' in plugins:
680
 
        get_fastimport_py2exe_info(includes, excludes, packages)
681
 
 
682
662
    if "TBZR" in os.environ:
683
663
        # TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
684
664
        # TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
708
688
 
709
689
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
710
690
    # in on Vista.
711
 
    dll_excludes.extend(["MSWSOCK.dll",
712
 
                         "MSVCP60.dll",
713
 
                         "MSVCP90.dll",
714
 
                         "powrprof.dll",
715
 
                         "SHFOLDER.dll"])
 
691
    dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
716
692
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
717
693
                               "includes": includes,
718
694
                               "excludes": excludes,
734
710
            self.optimize = 2
735
711
 
736
712
    if __name__ == '__main__':
737
 
        command_classes['install_data'] = install_data_with_bytecompile
738
 
        command_classes['py2exe'] = py2exe_no_oo_exe
739
713
        setup(options=options_list,
740
714
              console=console_targets,
741
715
              windows=gui_targets,
742
716
              zipfile='lib/library.zip',
743
717
              data_files=data_files,
744
 
              cmdclass=command_classes,
 
718
              cmdclass={'install_data': install_data_with_bytecompile,
 
719
                        'py2exe': py2exe_no_oo_exe},
745
720
              )
746
721
 
747
722
else:
752
727
        # easy_install one
753
728
        DATA_FILES = [('man/man1', ['bzr.1'])]
754
729
 
 
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
 
755
743
    # std setup
756
744
    ARGS = {'scripts': ['bzr'],
757
745
            'data_files': DATA_FILES,