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