Mercurial > public > mercurial-scm > hg
diff setup.py @ 1283:f5faab34f32e
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.
author | Volker.Kleinfeld@gmx.de |
---|---|
date | Tue, 20 Sep 2005 19:25:14 -0700 |
parents | 7f5ce4bbdd7b |
children | 59d07a6bd513 |
line wrap: on
line diff
--- a/setup.py Tue Sep 20 11:38:01 2005 -0700 +++ b/setup.py Tue Sep 20 19:25:14 2005 -0700 @@ -11,6 +11,34 @@ import mercurial.version +# py2exe needs to be installed to work +try: + import py2exe + + # Due to the use of demandload py2exe is not finding the modules. + # packagescan.getmodules creates a list of modules included in + # the mercurial package plus depdent modules. + import mercurial.packagescan + from py2exe.build_exe import py2exe as build_exe + + class py2exe_for_demandload(build_exe): + """ overwrites the py2exe command class for getting the build + directory and for setting the 'includes' option.""" + def initialize_options(self): + self.build_lib = None + build_exe.initialize_options(self) + def finalize_options(self): + # Get the build directory, ie. where to search for modules. + self.set_undefined_options('build', + ('build_lib', 'build_lib')) + # Sets the 'includes' option with the list of needed modules + if not self.includes: + self.includes = [] + self.includes += mercurial.packagescan.getmodules(self.build_lib,'mercurial') + build_exe.finalize_options(self) +except ImportError: pass + + # specify version string, otherwise 'hg identify' will be used: version = '' @@ -36,7 +64,9 @@ ['templates/map'] + glob.glob('templates/map-*') + glob.glob('templates/*.tmpl'))], - cmdclass = { 'install_data' : install_package_data }, - scripts=['hg', 'hgmerge']) + cmdclass = { 'install_data' : install_package_data, + 'py2exe' : py2exe_for_demandload}, + scripts=['hg', 'hgmerge'], + console = ['hg']) finally: mercurial.version.forget_version()