~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Vincent Ladeuil
  • Date: 2010-10-07 06:08:01 UTC
  • mto: This revision was merged to the branch mainline in revision 5491.
  • Revision ID: v.ladeuil+lp@free.fr-20101007060801-wfdhizfhfmctl8qa
Fix some typos and propose a release planning.

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"""
157
151
    Generate bzr.1.
158
152
    """
159
153
 
160
 
    sub_commands = build.sub_commands + [
161
 
            ('build_mo', lambda _: True),
162
 
            ]
163
 
 
164
154
    def run(self):
165
155
        build.run(self)
166
156
 
172
162
## Setup
173
163
########################
174
164
 
175
 
from tools.build_mo import build_mo
176
 
 
177
165
command_classes = {'install_scripts': my_install_scripts,
178
 
                   'build': bzr_build,
179
 
                   'build_mo': build_mo,
180
 
                   }
 
166
                   'build': bzr_build}
181
167
from distutils import log
182
168
from distutils.errors import CCompilerError, DistutilsPlatformError
183
169
from distutils.extension import Extension
184
170
ext_modules = []
185
171
try:
186
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...")
187
177
        from Cython.Distutils import build_ext
188
178
        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
179
except ImportError:
194
180
    have_pyrex = False
195
181
    # try to build the extension from the prior generated source.
202
188
    from distutils.command.build_ext import build_ext
203
189
else:
204
190
    have_pyrex = True
205
 
    import re
206
 
    _version = re.match("^[0-9.]+", pyrex_version).group(0)
207
 
    pyrex_version_info = tuple(map(int, _version.split('.')))
 
191
    pyrex_version_info = tuple(map(int, pyrex_version.split('.')))
208
192
 
209
193
 
210
194
class build_ext_if_possible(build_ext):
306
290
        # The code it generates re-uses a "local" pointer and
307
291
        # calls "PY_DECREF" after having set it to NULL. (It mixes PY_XDECREF
308
292
        # which is NULL safe with PY_DECREF which is not.)
309
 
        # <https://bugs.launchpad.net/bzr/+bug/449372>
310
 
        # <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>
311
295
        print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
312
 
        print('your version of pyrex "%s". Please upgrade your pyrex'
313
 
              % (pyrex_version,))
 
296
        print('your version of pyrex "%s". Please upgrade your pyrex' % (
 
297
            pyrex_version,))
314
298
        print('install. For now, the non-compiled (python) version will')
315
299
        print('be used instead.')
316
300
    else:
410
394
    # ditto for the tbzrcommand tool
411
395
    tbzrcommand = dict(
412
396
        script = os.path.join(tbzr_root, "scripts", "tbzrcommand.py"),
413
 
        icon_resources = icon_resources,
414
 
        other_resources = other_resources,
 
397
        icon_resources = [(0,'bzr.ico')],
415
398
    )
416
399
    console_targets.append(tbzrcommand)
417
400
    tbzrcommandw = tbzrcommand.copy()
484
467
    packages.append('sqlite3')
485
468
 
486
469
 
487
 
def get_fastimport_py2exe_info(includes, excludes, packages):
488
 
    # This is the python-fastimport package, not to be confused with the
489
 
    # bzr-fastimport plugin.
490
 
    packages.append('fastimport')
491
 
 
492
 
 
493
470
if 'bdist_wininst' in sys.argv:
494
471
    def find_docs():
495
472
        docs = []
514
491
            # help pages
515
492
            'data_files': find_docs(),
516
493
            # for building pyrex extensions
517
 
            'cmdclass': command_classes,
 
494
            'cmdclass': {'build_ext': build_ext_if_possible},
518
495
           }
519
496
 
520
497
    ARGS.update(META_INFO)
521
498
    ARGS.update(BZRLIB)
522
 
    PKG_DATA['package_data']['bzrlib'].append('locale/*/LC_MESSAGES/*.mo')
523
499
    ARGS.update(PKG_DATA)
524
 
 
 
500
    
525
501
    setup(**ARGS)
526
502
 
527
503
elif 'py2exe' in sys.argv:
 
504
    import glob
528
505
    # py2exe setup
529
506
    import py2exe
530
507
 
674
651
                       'tools/win32/bzr_postinstall.py',
675
652
                       ]
676
653
    gui_targets = [gui_target]
677
 
    data_files = topics_files + plugins_files + I18N_FILES
 
654
    data_files = topics_files + plugins_files
678
655
 
679
656
    if 'qbzr' in plugins:
680
657
        get_qbzr_py2exe_info(includes, excludes, packages, data_files)
682
659
    if 'svn' in plugins:
683
660
        get_svn_py2exe_info(includes, excludes, packages)
684
661
 
685
 
    if 'fastimport' in plugins:
686
 
        get_fastimport_py2exe_info(includes, excludes, packages)
687
 
 
688
662
    if "TBZR" in os.environ:
689
663
        # TORTOISE_OVERLAYS_MSI_WIN32 must be set to the location of the
690
664
        # TortoiseOverlays MSI installer file. It is in the TSVN svn repo and
714
688
 
715
689
    # MSWSOCK.dll is a system-specific library, which py2exe accidentally pulls
716
690
    # in on Vista.
717
 
    dll_excludes.extend(["MSWSOCK.dll",
718
 
                         "MSVCP60.dll",
719
 
                         "MSVCP90.dll",
720
 
                         "powrprof.dll",
721
 
                         "SHFOLDER.dll"])
 
691
    dll_excludes.extend(["MSWSOCK.dll", "MSVCP60.dll", "powrprof.dll"])
722
692
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
723
693
                               "includes": includes,
724
694
                               "excludes": excludes,
740
710
            self.optimize = 2
741
711
 
742
712
    if __name__ == '__main__':
743
 
        command_classes['install_data'] = install_data_with_bytecompile
744
 
        command_classes['py2exe'] = py2exe_no_oo_exe
745
713
        setup(options=options_list,
746
714
              console=console_targets,
747
715
              windows=gui_targets,
748
716
              zipfile='lib/library.zip',
749
717
              data_files=data_files,
750
 
              cmdclass=command_classes,
 
718
              cmdclass={'install_data': install_data_with_bytecompile,
 
719
                        'py2exe': py2exe_no_oo_exe},
751
720
              )
752
721
 
753
722
else:
758
727
        # easy_install one
759
728
        DATA_FILES = [('man/man1', ['bzr.1'])]
760
729
 
761
 
    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
 
762
743
    # std setup
763
744
    ARGS = {'scripts': ['bzr'],
764
745
            'data_files': DATA_FILES,