##// END OF EJS Templates
Add hgext.zeroconf to the package list so it gets installed by setup.py.
Augie Fackler -
r7081:2fdbf2cc default
parent child Browse files
Show More
@@ -1,144 +1,144 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 import shutil
13 import shutil
14 import tempfile
14 import tempfile
15 from distutils.core import setup, Extension
15 from distutils.core import setup, Extension
16 from distutils.command.install_data import install_data
16 from distutils.command.install_data import install_data
17 from distutils.ccompiler import new_compiler
17 from distutils.ccompiler import new_compiler
18
18
19 import mercurial.version
19 import mercurial.version
20
20
21 extra = {}
21 extra = {}
22 scripts = ['hg']
22 scripts = ['hg']
23 if os.name == 'nt':
23 if os.name == 'nt':
24 scripts.append('contrib/win32/hg.bat')
24 scripts.append('contrib/win32/hg.bat')
25
25
26 # simplified version of distutils.ccompiler.CCompiler.has_function
26 # simplified version of distutils.ccompiler.CCompiler.has_function
27 # that actually removes its temporary files.
27 # that actually removes its temporary files.
28 def has_function(cc, funcname):
28 def has_function(cc, funcname):
29 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
29 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
30 devnull = oldstderr = None
30 devnull = oldstderr = None
31 try:
31 try:
32 try:
32 try:
33 fname = os.path.join(tmpdir, 'funcname.c')
33 fname = os.path.join(tmpdir, 'funcname.c')
34 f = open(fname, 'w')
34 f = open(fname, 'w')
35 f.write('int main(void) {\n')
35 f.write('int main(void) {\n')
36 f.write(' %s();\n' % funcname)
36 f.write(' %s();\n' % funcname)
37 f.write('}\n')
37 f.write('}\n')
38 f.close()
38 f.close()
39 # Redirect stderr to /dev/null to hide any error messages
39 # Redirect stderr to /dev/null to hide any error messages
40 # from the compiler.
40 # from the compiler.
41 # This will have to be changed if we ever have to check
41 # This will have to be changed if we ever have to check
42 # for a function on Windows.
42 # for a function on Windows.
43 devnull = open('/dev/null', 'w')
43 devnull = open('/dev/null', 'w')
44 oldstderr = os.dup(sys.stderr.fileno())
44 oldstderr = os.dup(sys.stderr.fileno())
45 os.dup2(devnull.fileno(), sys.stderr.fileno())
45 os.dup2(devnull.fileno(), sys.stderr.fileno())
46 objects = cc.compile([fname])
46 objects = cc.compile([fname])
47 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
47 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
48 except:
48 except:
49 return False
49 return False
50 return True
50 return True
51 finally:
51 finally:
52 if oldstderr is not None:
52 if oldstderr is not None:
53 os.dup2(oldstderr, sys.stderr.fileno())
53 os.dup2(oldstderr, sys.stderr.fileno())
54 if devnull is not None:
54 if devnull is not None:
55 devnull.close()
55 devnull.close()
56 shutil.rmtree(tmpdir)
56 shutil.rmtree(tmpdir)
57
57
58 # py2exe needs to be installed to work
58 # py2exe needs to be installed to work
59 try:
59 try:
60 import py2exe
60 import py2exe
61
61
62 # Help py2exe to find win32com.shell
62 # Help py2exe to find win32com.shell
63 try:
63 try:
64 import modulefinder
64 import modulefinder
65 import win32com
65 import win32com
66 for p in win32com.__path__[1:]: # Take the path to win32comext
66 for p in win32com.__path__[1:]: # Take the path to win32comext
67 modulefinder.AddPackagePath("win32com", p)
67 modulefinder.AddPackagePath("win32com", p)
68 pn = "win32com.shell"
68 pn = "win32com.shell"
69 __import__(pn)
69 __import__(pn)
70 m = sys.modules[pn]
70 m = sys.modules[pn]
71 for p in m.__path__[1:]:
71 for p in m.__path__[1:]:
72 modulefinder.AddPackagePath(pn, p)
72 modulefinder.AddPackagePath(pn, p)
73 except ImportError:
73 except ImportError:
74 pass
74 pass
75
75
76 extra['console'] = ['hg']
76 extra['console'] = ['hg']
77
77
78 except ImportError:
78 except ImportError:
79 pass
79 pass
80
80
81 # specify version string, otherwise 'hg identify' will be used:
81 # specify version string, otherwise 'hg identify' will be used:
82 version = ''
82 version = ''
83
83
84 class install_package_data(install_data):
84 class install_package_data(install_data):
85 def finalize_options(self):
85 def finalize_options(self):
86 self.set_undefined_options('install',
86 self.set_undefined_options('install',
87 ('install_lib', 'install_dir'))
87 ('install_lib', 'install_dir'))
88 install_data.finalize_options(self)
88 install_data.finalize_options(self)
89
89
90 mercurial.version.remember_version(version)
90 mercurial.version.remember_version(version)
91 cmdclass = {'install_data': install_package_data}
91 cmdclass = {'install_data': install_package_data}
92
92
93 ext_modules=[
93 ext_modules=[
94 Extension('mercurial.base85', ['mercurial/base85.c']),
94 Extension('mercurial.base85', ['mercurial/base85.c']),
95 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
95 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
96 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
96 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
97 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
97 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
98 Extension('mercurial.parsers', ['mercurial/parsers.c']),
98 Extension('mercurial.parsers', ['mercurial/parsers.c']),
99 ]
99 ]
100
100
101 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
101 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
102 'hgext.highlight']
102 'hgext.highlight', 'hgext.zeroconf', ]
103
103
104 try:
104 try:
105 import msvcrt
105 import msvcrt
106 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
106 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
107 except ImportError:
107 except ImportError:
108 pass
108 pass
109
109
110 try:
110 try:
111 import posix
111 import posix
112 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
112 ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
113
113
114 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
114 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
115 # The inotify extension is only usable with Linux 2.6 kernels.
115 # The inotify extension is only usable with Linux 2.6 kernels.
116 # You also need a reasonably recent C library.
116 # You also need a reasonably recent C library.
117 cc = new_compiler()
117 cc = new_compiler()
118 if has_function(cc, 'inotify_add_watch'):
118 if has_function(cc, 'inotify_add_watch'):
119 ext_modules.append(Extension('hgext.inotify.linux._inotify',
119 ext_modules.append(Extension('hgext.inotify.linux._inotify',
120 ['hgext/inotify/linux/_inotify.c']))
120 ['hgext/inotify/linux/_inotify.c']))
121 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
121 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
122 except ImportError:
122 except ImportError:
123 pass
123 pass
124
124
125 setup(name='mercurial',
125 setup(name='mercurial',
126 version=mercurial.version.get_version(),
126 version=mercurial.version.get_version(),
127 author='Matt Mackall',
127 author='Matt Mackall',
128 author_email='mpm@selenic.com',
128 author_email='mpm@selenic.com',
129 url='http://selenic.com/mercurial',
129 url='http://selenic.com/mercurial',
130 description='Scalable distributed SCM',
130 description='Scalable distributed SCM',
131 license='GNU GPL',
131 license='GNU GPL',
132 scripts=scripts,
132 scripts=scripts,
133 packages=packages,
133 packages=packages,
134 ext_modules=ext_modules,
134 ext_modules=ext_modules,
135 data_files=[(os.path.join('mercurial', root),
135 data_files=[(os.path.join('mercurial', root),
136 [os.path.join(root, file_) for file_ in files])
136 [os.path.join(root, file_) for file_ in files])
137 for root, dirs, files in os.walk('templates')],
137 for root, dirs, files in os.walk('templates')],
138 cmdclass=cmdclass,
138 cmdclass=cmdclass,
139 options=dict(py2exe=dict(packages=['hgext', 'email']),
139 options=dict(py2exe=dict(packages=['hgext', 'email']),
140 bdist_mpkg=dict(zipdist=True,
140 bdist_mpkg=dict(zipdist=True,
141 license='COPYING',
141 license='COPYING',
142 readme='contrib/macosx/Readme.html',
142 readme='contrib/macosx/Readme.html',
143 welcome='contrib/macosx/Welcome.html')),
143 welcome='contrib/macosx/Welcome.html')),
144 **extra)
144 **extra)
General Comments 0
You need to be logged in to leave comments. Login now