8 import glob |
8 import glob |
9 from distutils.core import setup, Extension |
9 from distutils.core import setup, Extension |
10 from distutils.command.install_data import install_data |
10 from distutils.command.install_data import install_data |
11 |
11 |
12 import mercurial.version |
12 import mercurial.version |
|
13 |
|
14 # py2exe needs to be installed to work |
|
15 try: |
|
16 import py2exe |
|
17 |
|
18 # Due to the use of demandload py2exe is not finding the modules. |
|
19 # packagescan.getmodules creates a list of modules included in |
|
20 # the mercurial package plus depdent modules. |
|
21 import mercurial.packagescan |
|
22 from py2exe.build_exe import py2exe as build_exe |
|
23 |
|
24 class py2exe_for_demandload(build_exe): |
|
25 """ overwrites the py2exe command class for getting the build |
|
26 directory and for setting the 'includes' option.""" |
|
27 def initialize_options(self): |
|
28 self.build_lib = None |
|
29 build_exe.initialize_options(self) |
|
30 def finalize_options(self): |
|
31 # Get the build directory, ie. where to search for modules. |
|
32 self.set_undefined_options('build', |
|
33 ('build_lib', 'build_lib')) |
|
34 # Sets the 'includes' option with the list of needed modules |
|
35 if not self.includes: |
|
36 self.includes = [] |
|
37 self.includes += mercurial.packagescan.getmodules(self.build_lib,'mercurial') |
|
38 build_exe.finalize_options(self) |
|
39 except ImportError: pass |
|
40 |
13 |
41 |
14 # specify version string, otherwise 'hg identify' will be used: |
42 # specify version string, otherwise 'hg identify' will be used: |
15 version = '' |
43 version = '' |
16 |
44 |
17 class install_package_data(install_data): |
45 class install_package_data(install_data): |
34 Extension('mercurial.bdiff', ['mercurial/bdiff.c'])], |
62 Extension('mercurial.bdiff', ['mercurial/bdiff.c'])], |
35 data_files=[('mercurial/templates', |
63 data_files=[('mercurial/templates', |
36 ['templates/map'] + |
64 ['templates/map'] + |
37 glob.glob('templates/map-*') + |
65 glob.glob('templates/map-*') + |
38 glob.glob('templates/*.tmpl'))], |
66 glob.glob('templates/*.tmpl'))], |
39 cmdclass = { 'install_data' : install_package_data }, |
67 cmdclass = { 'install_data' : install_package_data, |
40 scripts=['hg', 'hgmerge']) |
68 'py2exe' : py2exe_for_demandload}, |
|
69 scripts=['hg', 'hgmerge'], |
|
70 console = ['hg']) |
41 finally: |
71 finally: |
42 mercurial.version.forget_version() |
72 mercurial.version.forget_version() |