##// END OF EJS Templates
setup.py: skip inotify if there's no inotify_add_watch...
Alexis S. L. Carvalho -
r6245:0d0939b2 default
parent child Browse files
Show More
@@ -1,95 +1,99 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 # 'python setup.py install', or
5 # 'python setup.py install', or
6 # 'python setup.py --help' for more options
6 # 'python setup.py --help' for more options
7
7
8 import sys
8 import sys
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
10 raise SystemExit, "Mercurial requires python 2.3 or later."
10 raise SystemExit, "Mercurial requires python 2.3 or later."
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 from distutils.ccompiler import new_compiler
15
16
16 import mercurial.version
17 import mercurial.version
17
18
18 extra = {}
19 extra = {}
19
20
20 # py2exe needs to be installed to work
21 # py2exe needs to be installed to work
21 try:
22 try:
22 import py2exe
23 import py2exe
23
24
24 # Help py2exe to find win32com.shell
25 # Help py2exe to find win32com.shell
25 try:
26 try:
26 import modulefinder
27 import modulefinder
27 import win32com
28 import win32com
28 for p in win32com.__path__[1:]: # Take the path to win32comext
29 for p in win32com.__path__[1:]: # Take the path to win32comext
29 modulefinder.AddPackagePath("win32com", p)
30 modulefinder.AddPackagePath("win32com", p)
30 pn = "win32com.shell"
31 pn = "win32com.shell"
31 __import__(pn)
32 __import__(pn)
32 m = sys.modules[pn]
33 m = sys.modules[pn]
33 for p in m.__path__[1:]:
34 for p in m.__path__[1:]:
34 modulefinder.AddPackagePath(pn, p)
35 modulefinder.AddPackagePath(pn, p)
35 except ImportError:
36 except ImportError:
36 pass
37 pass
37
38
38 extra['console'] = ['hg']
39 extra['console'] = ['hg']
39
40
40 except ImportError:
41 except ImportError:
41 pass
42 pass
42
43
43 # specify version string, otherwise 'hg identify' will be used:
44 # specify version string, otherwise 'hg identify' will be used:
44 version = ''
45 version = ''
45
46
46 class install_package_data(install_data):
47 class install_package_data(install_data):
47 def finalize_options(self):
48 def finalize_options(self):
48 self.set_undefined_options('install',
49 self.set_undefined_options('install',
49 ('install_lib', 'install_dir'))
50 ('install_lib', 'install_dir'))
50 install_data.finalize_options(self)
51 install_data.finalize_options(self)
51
52
52 mercurial.version.remember_version(version)
53 mercurial.version.remember_version(version)
53 cmdclass = {'install_data': install_package_data}
54 cmdclass = {'install_data': install_package_data}
54
55
55 ext_modules=[
56 ext_modules=[
56 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
57 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
57 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
58 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
58 Extension('mercurial.base85', ['mercurial/base85.c']),
59 Extension('mercurial.base85', ['mercurial/base85.c']),
59 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'])
60 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'])
60 ]
61 ]
61
62
62 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert']
63 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert']
63
64
64 try:
65 try:
65 import posix
66 import posix
66 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
67 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
67
68
68 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
69 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
69 # the inotify extension is only usable with Linux 2.6 kernels
70 # The inotify extension is only usable with Linux 2.6 kernels.
70 ext_modules.append(Extension('hgext.inotify.linux._inotify',
71 # You also need a reasonably recent C library.
71 ['hgext/inotify/linux/_inotify.c']))
72 cc = new_compiler()
72 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
73 if cc.has_function('inotify_add_watch'):
74 ext_modules.append(Extension('hgext.inotify.linux._inotify',
75 ['hgext/inotify/linux/_inotify.c']))
76 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
73 except ImportError:
77 except ImportError:
74 pass
78 pass
75
79
76 setup(name='mercurial',
80 setup(name='mercurial',
77 version=mercurial.version.get_version(),
81 version=mercurial.version.get_version(),
78 author='Matt Mackall',
82 author='Matt Mackall',
79 author_email='mpm@selenic.com',
83 author_email='mpm@selenic.com',
80 url='http://selenic.com/mercurial',
84 url='http://selenic.com/mercurial',
81 description='Scalable distributed SCM',
85 description='Scalable distributed SCM',
82 license='GNU GPL',
86 license='GNU GPL',
83 scripts=['hg'],
87 scripts=['hg'],
84 packages=packages,
88 packages=packages,
85 ext_modules=ext_modules,
89 ext_modules=ext_modules,
86 data_files=[(os.path.join('mercurial', root),
90 data_files=[(os.path.join('mercurial', root),
87 [os.path.join(root, file_) for file_ in files])
91 [os.path.join(root, file_) for file_ in files])
88 for root, dirs, files in os.walk('templates')],
92 for root, dirs, files in os.walk('templates')],
89 cmdclass=cmdclass,
93 cmdclass=cmdclass,
90 options=dict(py2exe=dict(packages=['hgext']),
94 options=dict(py2exe=dict(packages=['hgext']),
91 bdist_mpkg=dict(zipdist=True,
95 bdist_mpkg=dict(zipdist=True,
92 license='COPYING',
96 license='COPYING',
93 readme='contrib/macosx/Readme.html',
97 readme='contrib/macosx/Readme.html',
94 welcome='contrib/macosx/Welcome.html')),
98 welcome='contrib/macosx/Welcome.html')),
95 **extra)
99 **extra)
General Comments 0
You need to be logged in to leave comments. Login now