setup.py
author Matt Mackall <mpm@selenic.com>
Mon, 03 Oct 2005 13:45:59 -0700
changeset 1373 965d1db5c95d
parent 1301 0e921c164b58
child 1421 a7631cf1326a
permissions -rw-r--r--
hg log: add -k for keyword searching
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
72
4a6ab4d80dc4 Add an O(m + nlog n) patching extension
mpm@selenic.com
parents: 67
diff changeset
     9
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
    10
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
    11
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    12
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
    13
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    14
# py2exe needs to be installed to work
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    15
try:
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    16
    import py2exe
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    17
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    18
    # 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
    19
    # 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
    20
    # the mercurial package plus depdent modules.
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    21
    import mercurial.packagescan
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    22
    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
    23
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    24
    class py2exe_for_demandload(build_exe):
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    25
        """ 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
    26
        directory and for setting the 'includes' option."""
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    27
        def initialize_options(self):
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    28
            self.build_lib = None
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    29
            build_exe.initialize_options(self)
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    30
        def finalize_options(self):
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    31
            # 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
    32
            self.set_undefined_options('build',
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    33
                                       ('build_lib', 'build_lib'))
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    34
            # 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
    35
            if not self.includes:
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    36
                self.includes = []
1294
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    37
            self.includes += mercurial.packagescan.getmodules(self.build_lib,
372971e1c40d Clean up whitespace damage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1284
diff changeset
    38
                                                              'mercurial')
1300
e58b1c9a0dec Rename mercurial.ext to hgext.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1299
diff changeset
    39
            self.includes += mercurial.packagescan.getmodules(self.build_lib,
e58b1c9a0dec Rename mercurial.ext to hgext.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1299
diff changeset
    40
                                                              'hgext')
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    41
            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
    42
except ImportError:
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    43
    py2exe_for_demandload = None
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    44
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    45
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    46
# 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
    47
version = ''
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    48
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    49
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
    50
    def finalize_options(self):
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    51
        self.set_undefined_options('install',
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    52
                                   ('install_lib', 'install_dir'))
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    53
        install_data.finalize_options(self)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    54
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    55
try:
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    56
    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
    57
    cmdclass = {'install_data': install_package_data}
59d07a6bd513 Fix Volker's modifications to setup.py for non-Windows systems.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1283
diff changeset
    58
    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
    59
        cmdclass['py2exe'] = py2exe_for_demandload
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    60
    setup(name='mercurial',
429
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    61
          version=mercurial.version.get_version(),
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    62
          author='Matt Mackall',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    63
          author_email='mpm@selenic.com',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    64
          url='http://selenic.com/mercurial',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    65
          description='scalable distributed SCM',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    66
          license='GNU GPL',
1301
0e921c164b58 Fix small thinko.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1300
diff changeset
    67
          packages=['mercurial', 'hgext'],
429
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    68
          ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    69
                       Extension('mercurial.bdiff', ['mercurial/bdiff.c'])],
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    70
          data_files=[('mercurial/templates',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    71
                       ['templates/map'] +
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    72
                       glob.glob('templates/map-*') +
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
    73
                       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
    74
          cmdclass=cmdclass,
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    75
          scripts=['hg', 'hgmerge'],
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    76
          console = ['hg'])
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    77
finally:
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    78
    mercurial.version.forget_version()