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 |
|
17 import mercurial.demandimport |
|
18 mercurial.demandimport.enable = lambda: None |
|
19 |
|
20 extra = {} |
19 |
21 |
20 # py2exe needs to be installed to work |
22 # py2exe needs to be installed to work |
21 try: |
23 try: |
22 import py2exe |
24 import py2exe |
23 |
25 |
33 for p in m.__path__[1:]: |
35 for p in m.__path__[1:]: |
34 modulefinder.AddPackagePath(pn, p) |
36 modulefinder.AddPackagePath(pn, p) |
35 except ImportError: |
37 except ImportError: |
36 pass |
38 pass |
37 |
39 |
38 # Due to the use of demandload py2exe is not finding the modules. |
40 extra['console'] = ['hg'] |
39 # packagescan.getmodules creates a list of modules included in |
|
40 # the mercurial package plus dependant modules. |
|
41 from py2exe.build_exe import py2exe as build_exe |
|
42 |
41 |
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: |
42 except ImportError: |
64 py2exe_for_demandload = None |
43 pass |
65 |
|
66 |
44 |
67 # specify version string, otherwise 'hg identify' will be used: |
45 # specify version string, otherwise 'hg identify' will be used: |
68 version = '' |
46 version = '' |
69 |
47 |
70 class install_package_data(install_data): |
48 class install_package_data(install_data): |
73 ('install_lib', 'install_dir')) |
51 ('install_lib', 'install_dir')) |
74 install_data.finalize_options(self) |
52 install_data.finalize_options(self) |
75 |
53 |
76 mercurial.version.remember_version(version) |
54 mercurial.version.remember_version(version) |
77 cmdclass = {'install_data': install_package_data} |
55 cmdclass = {'install_data': install_package_data} |
78 py2exe_opts = {} |
|
79 if py2exe_for_demandload is not None: |
|
80 cmdclass['py2exe'] = py2exe_for_demandload |
|
81 py2exe_opts['console'] = ['hg'] |
|
82 |
56 |
83 setup(name='mercurial', |
57 setup(name='mercurial', |
84 version=mercurial.version.get_version(), |
58 version=mercurial.version.get_version(), |
85 author='Matt Mackall', |
59 author='Matt Mackall', |
86 author_email='mpm@selenic.com', |
60 author_email='mpm@selenic.com', |
98 scripts=['hg', 'hgmerge'], |
72 scripts=['hg', 'hgmerge'], |
99 options=dict(bdist_mpkg=dict(zipdist=True, |
73 options=dict(bdist_mpkg=dict(zipdist=True, |
100 license='COPYING', |
74 license='COPYING', |
101 readme='contrib/macosx/Readme.html', |
75 readme='contrib/macosx/Readme.html', |
102 welcome='contrib/macosx/Welcome.html')), |
76 welcome='contrib/macosx/Welcome.html')), |
103 **py2exe_opts) |
77 **extra) |