setup.py
changeset 3877 abaee83ce0a6
parent 3590 231e61de692c
child 3887 57b797601b61
equal deleted inserted replaced
3876:1e0b94cfba0e 3877:abaee83ce0a6
    11 
    11 
    12 import os
    12 import os
    13 from distutils.core import setup, Extension
    13 from distutils.core import setup, Extension
    14 from distutils.command.install_data import install_data
    14 from distutils.command.install_data import install_data
    15 
    15 
    16 # mercurial.packagescan must be the first mercurial module imported
       
    17 import mercurial.packagescan
       
    18 import mercurial.version
    16 import mercurial.version
    19 
    17 
    20 # py2exe needs to be installed to work
    18 # py2exe needs to be installed to work
    21 try:
    19 try:
    22     import py2exe
    20     import py2exe
    33         for p in m.__path__[1:]:
    31         for p in m.__path__[1:]:
    34             modulefinder.AddPackagePath(pn, p)
    32             modulefinder.AddPackagePath(pn, p)
    35     except ImportError:
    33     except ImportError:
    36         pass
    34         pass
    37 
    35 
    38     # Due to the use of demandload py2exe is not finding the modules.
       
    39     # packagescan.getmodules creates a list of modules included in
       
    40     # the mercurial package plus depdent modules.
       
    41     from py2exe.build_exe import py2exe as build_exe
       
    42 
       
    43     class py2exe_for_demandload(build_exe):
       
    44         """ overwrites the py2exe command class for getting the build
       
    45         directory and for setting the 'includes' option."""
       
    46         def initialize_options(self):
       
    47             self.build_lib = None
       
    48             build_exe.initialize_options(self)
       
    49         def finalize_options(self):
       
    50             # Get the build directory, ie. where to search for modules.
       
    51             self.set_undefined_options('build',
       
    52                                        ('build_lib', 'build_lib'))
       
    53             # Sets the 'includes' option with the list of needed modules
       
    54             if not self.includes:
       
    55                 self.includes = []
       
    56             else:
       
    57                 self.includes = self.includes.split(',')
       
    58             mercurial.packagescan.scan(self.build_lib, 'mercurial')
       
    59             mercurial.packagescan.scan(self.build_lib, 'mercurial.hgweb')
       
    60             mercurial.packagescan.scan(self.build_lib, 'hgext')
       
    61             self.includes += mercurial.packagescan.getmodules()
       
    62             build_exe.finalize_options(self)
       
    63 except ImportError:
    36 except ImportError:
    64     py2exe_for_demandload = None
    37     py2exe_for_demandload = None
    65 
    38 
    66 
    39 
    67 # specify version string, otherwise 'hg identify' will be used:
    40 # specify version string, otherwise 'hg identify' will be used: