setup.py
author Volker.Kleinfeld@gmx.de
Tue, 20 Sep 2005 19:25:14 -0700
changeset 1283 f5faab34f32e
parent 575 7f5ce4bbdd7b
child 1284 59d07a6bd513
permissions -rw-r--r--
Support for the distutils extention 'py2exe' added. Description: - If the py2exe distutils extention is installed this patch allows building standalone exe for windows - example: > python setup.py build --compiler=mingw32 py2exe - The 'out of the box' py2exe is not able to resolve the dependencies due to 'demandload'. A new helper module of scanning the mercurial package has been added. Changed: - setup.py: importing py2exe and sub classing its command class to fetch the build directory and insert the needed includes - packagescan.py: new helper module added, that scans the distutil build directory for modules to be included.
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:
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    16
    import py2exe 
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.
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    19
    # packagescan.getmodules creates a list of modules included in 
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    20
    # the mercurial package plus depdent modules.
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    21
    import mercurial.packagescan 
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    22
    from py2exe.build_exe import py2exe as build_exe 
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 = []
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    37
            self.includes += mercurial.packagescan.getmodules(self.build_lib,'mercurial')
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    38
            build_exe.finalize_options(self)
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    39
except ImportError: pass
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    40
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    41
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    42
# 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
    43
version = ''
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    44
157
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    45
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
    46
    def finalize_options(self):
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    47
        self.set_undefined_options('install',
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    48
                                   ('install_lib', 'install_dir'))
2653740d8118 Install the templates where they can be found by hgweb.py
mpm@selenic.com
parents: 155
diff changeset
    49
        install_data.finalize_options(self)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    50
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    51
try:
427
36e644d28edf Make it possible to specify a version number in setup.py.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 423
diff changeset
    52
    mercurial.version.remember_version(version)
423
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    53
    setup(name='mercurial',
429
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    54
          version=mercurial.version.get_version(),
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    55
          author='Matt Mackall',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    56
          author_email='mpm@selenic.com',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    57
          url='http://selenic.com/mercurial',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    58
          description='scalable distributed SCM',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    59
          license='GNU GPL',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    60
          packages=['mercurial'],
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    61
          ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    62
                       Extension('mercurial.bdiff', ['mercurial/bdiff.c'])],
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    63
          data_files=[('mercurial/templates',
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    64
                       ['templates/map'] +
688d03d6997a Pull from TAH
mpm@selenic.com
parents: 400 427
diff changeset
    65
                       glob.glob('templates/map-*') +
575
7f5ce4bbdd7b More whitespace cleanups
mpm@selenic.com
parents: 429
diff changeset
    66
                       glob.glob('templates/*.tmpl'))],
1283
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    67
          cmdclass = { 'install_data' : install_package_data,
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    68
                       'py2exe' : py2exe_for_demandload},
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    69
          scripts=['hg', 'hgmerge'],
f5faab34f32e Support for the distutils extention 'py2exe' added.
Volker.Kleinfeld@gmx.de
parents: 575
diff changeset
    70
          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
    71
finally:
25afb21d97ba Support for 'hg --version'. setup.py stores version from hg repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 241
diff changeset
    72
    mercurial.version.forget_version()