~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

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
67
66
            'package_data': {'bzrlib': ['doc/api/*.txt',
68
67
                                        'tests/test_patches_data/*',
69
68
                                        'help_topics/en/*.txt',
70
 
                                        'tests/ssl_certs/ca.crt',
71
69
                                        'tests/ssl_certs/server_without_pass.key',
72
70
                                        'tests/ssl_certs/server_with_pass.key',
73
 
                                        'tests/ssl_certs/server.crt',
 
71
                                        'tests/ssl_certs/server.crt'
74
72
                                       ]},
75
73
           }
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]))
 
74
 
81
75
 
82
76
def get_bzrlib_packages():
83
77
    """Recurse through the bzrlib directory, and extract the package names"""
105
99
 
106
100
from distutils import log
107
101
from distutils.core import setup
108
 
from distutils.version import LooseVersion
109
102
from distutils.command.install_scripts import install_scripts
110
103
from distutils.command.install_data import install_data
111
104
from distutils.command.build import build
158
151
    Generate bzr.1.
159
152
    """
160
153
 
161
 
    sub_commands = build.sub_commands + [
162
 
            ('build_mo', lambda _: True),
163
 
            ]
164
 
 
165
154
    def run(self):
166
155
        build.run(self)
167
156
 
173
162
## Setup
174
163
########################
175
164
 
176
 
from bzrlib.bzr_distutils import build_mo
177
 
 
178
165
command_classes = {'install_scripts': my_install_scripts,
179
 
                   'build': bzr_build,
180
 
                   'build_mo': build_mo,
181
 
                   }
 
166
                   'build': bzr_build}
182
167
from distutils import log
183
168
from distutils.errors import CCompilerError, DistutilsPlatformError
184
169
from distutils.extension import Extension
185
170
ext_modules = []
186
171
try:
187
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...")
188
177
        from Cython.Distutils import build_ext
189
178
        from Cython.Compiler.Version import version as pyrex_version
190
 
    except ImportError:
191
 
        print("No Cython, trying Pyrex...")
192
 
        from Pyrex.Distutils import build_ext
193
 
        from Pyrex.Compiler.Version import version as pyrex_version
194
179
except ImportError:
195
180
    have_pyrex = False
196
181
    # try to build the extension from the prior generated source.
203
188
    from distutils.command.build_ext import build_ext
204
189
else:
205
190
    have_pyrex = True
206
 
    pyrex_version_info = LooseVersion(pyrex_version)
 
191
    pyrex_version_info = tuple(map(int, pyrex_version.split('.')))
207
192
 
208
193
 
209
194
class build_ext_if_possible(build_ext):
300
285
                        libraries=['Ws2_32'])
301
286
    add_pyrex_extension('bzrlib._walkdirs_win32')
302
287
else:
303
 
    if have_pyrex and pyrex_version_info == LooseVersion("0.9.4.1"):
 
288
    if have_pyrex and pyrex_version_info[:3] == (0,9,4):
304
289
        # Pyrex 0.9.4.1 fails to compile this extension correctly
305
290
        # The code it generates re-uses a "local" pointer and
306
291
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
307
292
        # which is NULL safe with PY_DECREF which is not.)
308
 
        # <https://bugs.launchpad.net/bzr/+bug/449372>
309
 
        # <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>
310
295
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
311
 
        print('your version of pyrex "%s". Please upgrade your pyrex'
312
 
              % (pyrex_version,))
 
296
        print('your version of pyrex "%s". Please upgrade your pyrex' % (
 
297
            pyrex_version,))
313
298
        print('install. For now, the non-compiled (python) version will')
314
299
        print('be used instead.')
315
300
    else:
318
303
add_pyrex_extension('bzrlib._chk_map_pyx')
319
304
ext_modules.append(Extension('bzrlib._patiencediff_c',
320
305
                             ['bzrlib/_patiencediff_c.c']))
321
 
if have_pyrex and pyrex_version_info < LooseVersion("0.9.6.3"):
 
306
if have_pyrex and pyrex_version_info < (0, 9, 6, 3):
322
307
    print("")
323
308
    print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
324
309
        pyrex_version))
409
394
    # ditto for the tbzrcommand tool
410
395
    tbzrcommand = dict(
411
396
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
412
 
        icon_resources = icon_resources,
413
 
        other_resources = other_resources,
 
397
        icon_resources = [(0,'bzr.ico')],
414
398
    )
415
399
    console_targets.append(tbzrcommand)
416
400
    tbzrcommandw = tbzrcommand.copy()
432
416
    # PyQt4 itself still escapes the plugin detection code for some reason...
433
417
    includes.append('PyQt4.QtCore')
434
418
    includes.append('PyQt4.QtGui')
435
 
    includes.append('PyQt4.QtTest')
436
419
    includes.append('sip') # extension module required for Qt.
437
420
    packages.append('pygments') # colorizer for qbzr
438
421
    packages.append('docutils') # html formatting
484
467
    packages.append('sqlite3')
485
468
 
486
469
 
487
 
def get_git_py2exe_info(includes, excludes, packages):
488
 
    packages.append('dulwich')
489
 
 
490
 
 
491
 
def get_fastimport_py2exe_info(includes, excludes, packages):
492
 
    # This is the python-fastimport package, not to be confused with the
493
 
    # bzr-fastimport plugin.
494
 
    packages.append('fastimport')
495
 
 
496
 
 
497
470
if 'bdist_wininst' in sys.argv:
498
471
    def find_docs():
499
472
        docs = []
518
491
            # help pages
519
492
            'data_files': find_docs(),
520
493
            # for building pyrex extensions
521
 
            'cmdclass': command_classes,
 
494
            'cmdclass': {'build_ext': build_ext_if_possible},
522
495
           }
523
496
 
524
497
    ARGS.update(META_INFO)
525
498
    ARGS.update(BZRLIB)
526
 
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
527
499
    ARGS.update(PKG_DATA)
528
 
 
 
500
    
529
501
    setup(**ARGS)
530
502
 
531
503
elif 'py2exe' in sys.argv:
 
504
    import glob
532
505
    # py2exe setup
533
506
    import py2exe
534
507
 
678
651
                       'tools/win32/bzr_postinstall.py',
679
652
                       ]
680
653
    gui_targets = [gui_target]
681
 
    data_files = topics_files + plugins_files + I18N_FILES
 
654
    data_files = topics_files + plugins_files
682
655
 
683
656
    if 'qbzr' in plugins:
684
657
        get_qbzr_py2exe_info(includes, excludes, packages, data_files)
686
659
    if 'svn' in plugins:
687
660
        get_svn_py2exe_info(includes, excludes, packages)
688
661
 
689
 
    if 'git' in plugins:
690
 
        get_git_py2exe_info(includes, excludes, packages)
691
 
 
692
 
    if 'fastimport' in plugins:
693
 
        get_fastimport_py2exe_info(includes, excludes, packages)
694
 
 
695
662
    if "TBZR" in os.environ:
696
663
        # TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
697
664
        # TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
721
688
 
722
689
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
723
690
    # in on Vista.
724
 
    dll_excludes.extend(["MSWSOCK.dll",
725
 
                         "MSVCP60.dll",
726
 
                         "MSVCP90.dll",
727
 
                         "powrprof.dll",
728
 
                         "SHFOLDER.dll"])
 
691
    dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
729
692
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
730
693
                               "includes": includes,
731
694
                               "excludes": excludes,
747
710
            self.optimize = 2
748
711
 
749
712
    if __name__ == '__main__':
750
 
        command_classes['install_data'] = install_data_with_bytecompile
751
 
        command_classes['py2exe'] = py2exe_no_oo_exe
752
713
        setup(options=options_list,
753
714
              console=console_targets,
754
715
              windows=gui_targets,
755
716
              zipfile='lib/library.zip',
756
717
              data_files=data_files,
757
 
              cmdclass=command_classes,
 
718
              cmdclass={'install_data': install_data_with_bytecompile,
 
719
                        'py2exe': py2exe_no_oo_exe},
758
720
              )
759
721
 
760
722
else:
765
727
        # easy_install one
766
728
        DATA_FILES = [('man/man1', ['bzr.1'])]
767
729
 
768
 
    DATA_FILES = DATA_FILES + I18N_FILES
 
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
 
769
743
    # std setup
770
744
    ARGS = {'scripts': ['bzr'],
771
745
            'data_files': DATA_FILES,