setup.py
author Thomas Arendsen Hein <thomas@intevation.de>
Thu, 09 Feb 2006 07:24:34 +0100
changeset 1709 069129d24b26
parent 1688 43d3db1b8296
child 1777 a2316878f19d
permissions -rw-r--r--
Create default commit message in a more pythonic way.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     1
#!/usr/bin/env python
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
     2
#
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
     3
# This is the mercurial setup script.
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     4
#
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     5
# './setup.py install', or
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     6
# './setup.py --help' for more options
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     7
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
     8
import glob
1422
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
     9
import sys
72
4a6ab4d80dc4 Add an O(m + nlog n) patching extension
mpm@selenic.com
parents: 67
diff changeset
    10
from distutils.core import setup, Extension
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    11
from distutils.command.install_data import install_data
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    12
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    13
import mercurial.version
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    14
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    15
# py2exe needs to be installed to work
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    16
try:
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    17
    import py2exe
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    18
1422
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    19
    # Help py2exe to find win32com.shell
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    20
    try:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    21
        import modulefinder
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    22
        import win32com
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    23
        for p in win32com.__path__[1:]: # Take the path to win32comext
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    24
            modulefinder.AddPackagePath("win32com", p)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    25
        pn = "win32com.shell"
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    26
        __import__(pn)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    27
        m = sys.modules[pn]
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    28
        for p in m.__path__[1:]:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    29
            modulefinder.AddPackagePath(pn, p)
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    30
    except ImportError:
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    31
        pass
a7e8408ac79c py2exe is not able to handle win32com.shell
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1421
diff changeset
    32
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    33
    # Due to the use of demandload py2exe is not finding the modules.
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    34
    # packagescan.getmodules creates a list of modules included in
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    35
    # the mercurial package plus depdent modules.
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    36
    import mercurial.packagescan
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    37
    from py2exe.build_exe import py2exe as build_exe
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    38
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    39
    class py2exe_for_demandload(build_exe):
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    40
        """ overwrites the py2exe command class for getting the build
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    41
        directory and for setting the 'includes' option."""
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    42
        def initialize_options(self):
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    43
            self.build_lib = None
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    44
            build_exe.initialize_options(self)
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    45
        def finalize_options(self):
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    46
            # Get the build directory, ie. where to search for modules.
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    47
            self.set_undefined_options('build',
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    48
                                       ('build_lib', 'build_lib'))
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    49
            # Sets the 'includes' option with the list of needed modules
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    50
            if not self.includes:
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    51
                self.includes = []
1421
a7631cf1326a Option -i broken in py2exe_for_demandload
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1301
diff changeset
    52
            else:
a7631cf1326a Option -i broken in py2exe_for_demandload
Volker Kleinfeld <Volker.Kleinfeld@gmx.de>
parents: 1301
diff changeset
    53
                self.includes = self.includes.split(',')
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    54
            self.includes += mercurial.packagescan.getmodules(self.build_lib,
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    55
                                                              'mercurial')
1300
e58b1c9a0dec Rename mercurial.ext to hgext.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1299
diff changeset
    56
            self.includes += mercurial.packagescan.getmodules(self.build_lib,
e58b1c9a0dec Rename mercurial.ext to hgext.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1299
diff changeset
    57
                                                              'hgext')
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    58
            build_exe.finalize_options(self)
1284
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    59
except ImportError:
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    60
    py2exe_for_demandload = None
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    61
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    62
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    63
# specify version string, otherwise 'hg identify' will be used:
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    64
version = ''
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    65
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    66
class install_package_data(install_data):
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    67
    def finalize_options(self):
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    68
        self.set_undefined_options('install',
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    69
                                   ('install_lib', 'install_dir'))
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    70
        install_data.finalize_options(self)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    71
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    72
try:
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    73
    mercurial.version.remember_version(version)
1284
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    74
    cmdclass = {'install_data': install_package_data}
1508
b254243b7159 fix a warning when py2exe is not used
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1422
diff changeset
    75
    py2exe_opts = {}
1284
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    76
    if py2exe_for_demandload is not None:
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    77
        cmdclass['py2exe'] = py2exe_for_demandload
1548
18f3224da392 fix bug in setup.py introduced in r1508.
Will <will@glozer.net>
parents: 1508
diff changeset
    78
        py2exe_opts['console'] = ['hg']
1688
43d3db1b8296 Reverted name change (mercurial -> Mercurial) from dd5085897010.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1686
diff changeset
    79
    setup(name='mercurial',
429
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    80
          version=mercurial.version.get_version(),
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    81
          author='Matt Mackall',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    82
          author_email='mpm@selenic.com',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    83
          url='http://selenic.com/mercurial',
1686
dd5085897010 make stuff for macos x binary package.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1548
diff changeset
    84
          description='Scalable distributed SCM',
429
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    85
          license='GNU GPL',
1301
0e921c164b58 Fix small thinko.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1300
diff changeset
    86
          packages=['mercurial', 'hgext'],
429
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    87
          ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    88
                       Extension('mercurial.bdiff', ['mercurial/bdiff.c'])],
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    89
          data_files=[('mercurial/templates',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    90
                       ['templates/map'] +
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    91
                       glob.glob('templates/map-*') +
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
    92
                       glob.glob('templates/*.tmpl'))],
1284
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    93
          cmdclass=cmdclass,
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    94
          scripts=['hg', 'hgmerge'],
1686
dd5085897010 make stuff for macos x binary package.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1548
diff changeset
    95
          options=dict(bdist_mpkg=dict(zipdist=True,
dd5085897010 make stuff for macos x binary package.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1548
diff changeset
    96
                                       license='COPYING',
dd5085897010 make stuff for macos x binary package.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1548
diff changeset
    97
                                       readme='contrib/macosx/Readme.html',
dd5085897010 make stuff for macos x binary package.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1548
diff changeset
    98
                                       welcome='contrib/macosx/Welcome.html')),
1508
b254243b7159 fix a warning when py2exe is not used
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1422
diff changeset
    99
          **py2exe_opts)
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
   100
finally:
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
   101
    mercurial.version.forget_version()