##// END OF EJS Templates
fix a warning when py2exe is not used
Benoit Boissinot -
r1508:b254243b default
parent child Browse files
Show More
@@ -1,95 +1,97 b''
1 1 #!/usr/bin/env python
2 2 #
3 3 # This is the mercurial setup script.
4 4 #
5 5 # './setup.py install', or
6 6 # './setup.py --help' for more options
7 7
8 8 import glob
9 9 import sys
10 10 from distutils.core import setup, Extension
11 11 from distutils.command.install_data import install_data
12 12
13 13 import mercurial.version
14 14
15 15 # py2exe needs to be installed to work
16 16 try:
17 17 import py2exe
18 18
19 19 # Help py2exe to find win32com.shell
20 20 try:
21 21 import modulefinder
22 22 import win32com
23 23 for p in win32com.__path__[1:]: # Take the path to win32comext
24 24 modulefinder.AddPackagePath("win32com", p)
25 25 pn = "win32com.shell"
26 26 __import__(pn)
27 27 m = sys.modules[pn]
28 28 for p in m.__path__[1:]:
29 29 modulefinder.AddPackagePath(pn, p)
30 30 except ImportError:
31 31 pass
32 32
33 33 # Due to the use of demandload py2exe is not finding the modules.
34 34 # packagescan.getmodules creates a list of modules included in
35 35 # the mercurial package plus depdent modules.
36 36 import mercurial.packagescan
37 37 from py2exe.build_exe import py2exe as build_exe
38 38
39 39 class py2exe_for_demandload(build_exe):
40 40 """ overwrites the py2exe command class for getting the build
41 41 directory and for setting the 'includes' option."""
42 42 def initialize_options(self):
43 43 self.build_lib = None
44 44 build_exe.initialize_options(self)
45 45 def finalize_options(self):
46 46 # Get the build directory, ie. where to search for modules.
47 47 self.set_undefined_options('build',
48 48 ('build_lib', 'build_lib'))
49 49 # Sets the 'includes' option with the list of needed modules
50 50 if not self.includes:
51 51 self.includes = []
52 52 else:
53 53 self.includes = self.includes.split(',')
54 54 self.includes += mercurial.packagescan.getmodules(self.build_lib,
55 55 'mercurial')
56 56 self.includes += mercurial.packagescan.getmodules(self.build_lib,
57 57 'hgext')
58 58 build_exe.finalize_options(self)
59 59 except ImportError:
60 60 py2exe_for_demandload = None
61 61
62 62
63 63 # specify version string, otherwise 'hg identify' will be used:
64 64 version = ''
65 65
66 66 class install_package_data(install_data):
67 67 def finalize_options(self):
68 68 self.set_undefined_options('install',
69 69 ('install_lib', 'install_dir'))
70 70 install_data.finalize_options(self)
71 71
72 72 try:
73 73 mercurial.version.remember_version(version)
74 74 cmdclass = {'install_data': install_package_data}
75 py2exe_opts = {}
75 76 if py2exe_for_demandload is not None:
76 77 cmdclass['py2exe'] = py2exe_for_demandload
78 py2exe_opts['console'] = 'hg'
77 79 setup(name='mercurial',
78 80 version=mercurial.version.get_version(),
79 81 author='Matt Mackall',
80 82 author_email='mpm@selenic.com',
81 83 url='http://selenic.com/mercurial',
82 84 description='scalable distributed SCM',
83 85 license='GNU GPL',
84 86 packages=['mercurial', 'hgext'],
85 87 ext_modules=[Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
86 88 Extension('mercurial.bdiff', ['mercurial/bdiff.c'])],
87 89 data_files=[('mercurial/templates',
88 90 ['templates/map'] +
89 91 glob.glob('templates/map-*') +
90 92 glob.glob('templates/*.tmpl'))],
91 93 cmdclass=cmdclass,
92 94 scripts=['hg', 'hgmerge'],
93 console = ['hg'])
95 **py2exe_opts)
94 96 finally:
95 97 mercurial.version.forget_version()
General Comments 0
You need to be logged in to leave comments. Login now