##// END OF EJS Templates
setup/hg: always load Mercurial from where it was installed....
Dan Villiom Podlaski Christiansen -
r12661:10da5a1f default
parent child Browse files
Show More
@@ -1,27 +1,37
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 #
2 #
3 # mercurial - scalable distributed SCM
3 # mercurial - scalable distributed SCM
4 #
4 #
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
5 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
6 #
6 #
7 # This software may be used and distributed according to the terms of the
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2 or any later version.
8 # GNU General Public License version 2 or any later version.
9
9
10 import os
11 import sys
12
13 libdir = '@LIBDIR@'
14
15 if libdir != '@' 'LIBDIR' '@':
16 if not os.path.isabs(libdir):
17 libdir = os.path.join(os.path.dirname(__file__), libdir)
18 libdir = os.path.abspath(libdir)
19 sys.path.insert(0, libdir)
20
10 # enable importing on demand to reduce startup time
21 # enable importing on demand to reduce startup time
11 try:
22 try:
12 from mercurial import demandimport; demandimport.enable()
23 from mercurial import demandimport; demandimport.enable()
13 except ImportError:
24 except ImportError:
14 import sys
25 import sys
15 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
26 sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
16 ' '.join(sys.path))
27 ' '.join(sys.path))
17 sys.stderr.write("(check your install and PYTHONPATH)\n")
28 sys.stderr.write("(check your install and PYTHONPATH)\n")
18 sys.exit(-1)
29 sys.exit(-1)
19
30
20 import sys
21 import mercurial.util
31 import mercurial.util
22 import mercurial.dispatch
32 import mercurial.dispatch
23
33
24 for fp in (sys.stdin, sys.stdout, sys.stderr):
34 for fp in (sys.stdin, sys.stdout, sys.stderr):
25 mercurial.util.set_binary(fp)
35 mercurial.util.set_binary(fp)
26
36
27 mercurial.dispatch.run()
37 mercurial.dispatch.run()
@@ -1,347 +1,392
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, 4, 0, 'final'):
9 if not hasattr(sys, 'version_info') or sys.version_info < (2, 4, 0, 'final'):
10 raise SystemExit("Mercurial requires Python 2.4 or later.")
10 raise SystemExit("Mercurial requires Python 2.4 or later.")
11
11
12 if sys.version_info[0] >= 3:
12 if sys.version_info[0] >= 3:
13 def b(s):
13 def b(s):
14 '''A helper function to emulate 2.6+ bytes literals using string
14 '''A helper function to emulate 2.6+ bytes literals using string
15 literals.'''
15 literals.'''
16 return s.encode('latin1')
16 return s.encode('latin1')
17 else:
17 else:
18 def b(s):
18 def b(s):
19 '''A helper function to emulate 2.6+ bytes literals using string
19 '''A helper function to emulate 2.6+ bytes literals using string
20 literals.'''
20 literals.'''
21 return s
21 return s
22
22
23 # Solaris Python packaging brain damage
23 # Solaris Python packaging brain damage
24 try:
24 try:
25 import hashlib
25 import hashlib
26 sha = hashlib.sha1()
26 sha = hashlib.sha1()
27 except:
27 except:
28 try:
28 try:
29 import sha
29 import sha
30 except:
30 except:
31 raise SystemExit(
31 raise SystemExit(
32 "Couldn't import standard hashlib (incomplete Python install).")
32 "Couldn't import standard hashlib (incomplete Python install).")
33
33
34 try:
34 try:
35 import zlib
35 import zlib
36 except:
36 except:
37 raise SystemExit(
37 raise SystemExit(
38 "Couldn't import standard zlib (incomplete Python install).")
38 "Couldn't import standard zlib (incomplete Python install).")
39
39
40 try:
40 try:
41 import bz2
41 import bz2
42 except:
42 except:
43 raise SystemExit(
43 raise SystemExit(
44 "Couldn't import standard bz2 (incomplete Python install).")
44 "Couldn't import standard bz2 (incomplete Python install).")
45
45
46 import os, subprocess, time
46 import os, subprocess, time
47 import shutil
47 import shutil
48 import tempfile
48 import tempfile
49 from distutils import log
49 from distutils import log
50 from distutils.core import setup, Extension
50 from distutils.core import setup, Extension
51 from distutils.dist import Distribution
51 from distutils.dist import Distribution
52 from distutils.command.build import build
52 from distutils.command.build import build
53 from distutils.command.build_ext import build_ext
53 from distutils.command.build_ext import build_ext
54 from distutils.command.build_py import build_py
54 from distutils.command.build_py import build_py
55 from distutils.command.install_scripts import install_scripts
55 from distutils.spawn import spawn, find_executable
56 from distutils.spawn import spawn, find_executable
56 from distutils.ccompiler import new_compiler
57 from distutils.ccompiler import new_compiler
57 from distutils.errors import CCompilerError
58 from distutils.errors import CCompilerError
58 from distutils.sysconfig import get_python_inc
59 from distutils.sysconfig import get_python_inc
59
60
60 scripts = ['hg']
61 scripts = ['hg']
61 if os.name == 'nt':
62 if os.name == 'nt':
62 scripts.append('contrib/win32/hg.bat')
63 scripts.append('contrib/win32/hg.bat')
63
64
64 # simplified version of distutils.ccompiler.CCompiler.has_function
65 # simplified version of distutils.ccompiler.CCompiler.has_function
65 # that actually removes its temporary files.
66 # that actually removes its temporary files.
66 def hasfunction(cc, funcname):
67 def hasfunction(cc, funcname):
67 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
68 tmpdir = tempfile.mkdtemp(prefix='hg-install-')
68 devnull = oldstderr = None
69 devnull = oldstderr = None
69 try:
70 try:
70 try:
71 try:
71 fname = os.path.join(tmpdir, 'funcname.c')
72 fname = os.path.join(tmpdir, 'funcname.c')
72 f = open(fname, 'w')
73 f = open(fname, 'w')
73 f.write('int main(void) {\n')
74 f.write('int main(void) {\n')
74 f.write(' %s();\n' % funcname)
75 f.write(' %s();\n' % funcname)
75 f.write('}\n')
76 f.write('}\n')
76 f.close()
77 f.close()
77 # Redirect stderr to /dev/null to hide any error messages
78 # Redirect stderr to /dev/null to hide any error messages
78 # from the compiler.
79 # from the compiler.
79 # This will have to be changed if we ever have to check
80 # This will have to be changed if we ever have to check
80 # for a function on Windows.
81 # for a function on Windows.
81 devnull = open('/dev/null', 'w')
82 devnull = open('/dev/null', 'w')
82 oldstderr = os.dup(sys.stderr.fileno())
83 oldstderr = os.dup(sys.stderr.fileno())
83 os.dup2(devnull.fileno(), sys.stderr.fileno())
84 os.dup2(devnull.fileno(), sys.stderr.fileno())
84 objects = cc.compile([fname], output_dir=tmpdir)
85 objects = cc.compile([fname], output_dir=tmpdir)
85 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
86 cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
86 except:
87 except:
87 return False
88 return False
88 return True
89 return True
89 finally:
90 finally:
90 if oldstderr is not None:
91 if oldstderr is not None:
91 os.dup2(oldstderr, sys.stderr.fileno())
92 os.dup2(oldstderr, sys.stderr.fileno())
92 if devnull is not None:
93 if devnull is not None:
93 devnull.close()
94 devnull.close()
94 shutil.rmtree(tmpdir)
95 shutil.rmtree(tmpdir)
95
96
96 # py2exe needs to be installed to work
97 # py2exe needs to be installed to work
97 try:
98 try:
98 import py2exe
99 import py2exe
99 py2exeloaded = True
100 py2exeloaded = True
100
101
101 # Help py2exe to find win32com.shell
102 # Help py2exe to find win32com.shell
102 try:
103 try:
103 import modulefinder
104 import modulefinder
104 import win32com
105 import win32com
105 for p in win32com.__path__[1:]: # Take the path to win32comext
106 for p in win32com.__path__[1:]: # Take the path to win32comext
106 modulefinder.AddPackagePath("win32com", p)
107 modulefinder.AddPackagePath("win32com", p)
107 pn = "win32com.shell"
108 pn = "win32com.shell"
108 __import__(pn)
109 __import__(pn)
109 m = sys.modules[pn]
110 m = sys.modules[pn]
110 for p in m.__path__[1:]:
111 for p in m.__path__[1:]:
111 modulefinder.AddPackagePath(pn, p)
112 modulefinder.AddPackagePath(pn, p)
112 except ImportError:
113 except ImportError:
113 pass
114 pass
114
115
115 except ImportError:
116 except ImportError:
116 py2exeloaded = False
117 py2exeloaded = False
117 pass
118 pass
118
119
119 def runcmd(cmd, env):
120 def runcmd(cmd, env):
120 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
121 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
121 stderr=subprocess.PIPE, env=env)
122 stderr=subprocess.PIPE, env=env)
122 out, err = p.communicate()
123 out, err = p.communicate()
123 # If root is executing setup.py, but the repository is owned by
124 # If root is executing setup.py, but the repository is owned by
124 # another user (as in "sudo python setup.py install") we will get
125 # another user (as in "sudo python setup.py install") we will get
125 # trust warnings since the .hg/hgrc file is untrusted. That is
126 # trust warnings since the .hg/hgrc file is untrusted. That is
126 # fine, we don't want to load it anyway. Python may warn about
127 # fine, we don't want to load it anyway. Python may warn about
127 # a missing __init__.py in mercurial/locale, we also ignore that.
128 # a missing __init__.py in mercurial/locale, we also ignore that.
128 err = [e for e in err.splitlines()
129 err = [e for e in err.splitlines()
129 if not e.startswith(b('Not trusting file')) \
130 if not e.startswith(b('Not trusting file')) \
130 and not e.startswith(b('warning: Not importing'))]
131 and not e.startswith(b('warning: Not importing'))]
131 if err:
132 if err:
132 return ''
133 return ''
133 return out
134 return out
134
135
135 version = ''
136 version = ''
136
137
137 if os.path.isdir('.hg'):
138 if os.path.isdir('.hg'):
138 # Execute hg out of this directory with a custom environment which
139 # Execute hg out of this directory with a custom environment which
139 # includes the pure Python modules in mercurial/pure. We also take
140 # includes the pure Python modules in mercurial/pure. We also take
140 # care to not use any hgrc files and do no localization.
141 # care to not use any hgrc files and do no localization.
141 pypath = ['mercurial', os.path.join('mercurial', 'pure')]
142 pypath = ['mercurial', os.path.join('mercurial', 'pure')]
142 env = {'PYTHONPATH': os.pathsep.join(pypath),
143 env = {'PYTHONPATH': os.pathsep.join(pypath),
143 'HGRCPATH': '',
144 'HGRCPATH': '',
144 'LANGUAGE': 'C'}
145 'LANGUAGE': 'C'}
145 if 'LD_LIBRARY_PATH' in os.environ:
146 if 'LD_LIBRARY_PATH' in os.environ:
146 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
147 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
147 if 'SystemRoot' in os.environ:
148 if 'SystemRoot' in os.environ:
148 # Copy SystemRoot into the custom environment for Python 2.6
149 # Copy SystemRoot into the custom environment for Python 2.6
149 # under Windows. Otherwise, the subprocess will fail with
150 # under Windows. Otherwise, the subprocess will fail with
150 # error 0xc0150004. See: http://bugs.python.org/issue3440
151 # error 0xc0150004. See: http://bugs.python.org/issue3440
151 env['SystemRoot'] = os.environ['SystemRoot']
152 env['SystemRoot'] = os.environ['SystemRoot']
152 cmd = [sys.executable, 'hg', 'id', '-i', '-t']
153 cmd = [sys.executable, 'hg', 'id', '-i', '-t']
153 l = runcmd(cmd, env).split()
154 l = runcmd(cmd, env).split()
154 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
155 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
155 l.pop()
156 l.pop()
156 if len(l) > 1: # tag found
157 if len(l) > 1: # tag found
157 version = l[-1]
158 version = l[-1]
158 if l[0].endswith('+'): # propagate the dirty status to the tag
159 if l[0].endswith('+'): # propagate the dirty status to the tag
159 version += '+'
160 version += '+'
160 elif len(l) == 1: # no tag found
161 elif len(l) == 1: # no tag found
161 cmd = [sys.executable, 'hg', 'parents', '--template',
162 cmd = [sys.executable, 'hg', 'parents', '--template',
162 '{latesttag}+{latesttagdistance}-']
163 '{latesttag}+{latesttagdistance}-']
163 version = runcmd(cmd, env) + l[0]
164 version = runcmd(cmd, env) + l[0]
164 if version.endswith('+'):
165 if version.endswith('+'):
165 version += time.strftime('%Y%m%d')
166 version += time.strftime('%Y%m%d')
166 elif os.path.exists('.hg_archival.txt'):
167 elif os.path.exists('.hg_archival.txt'):
167 kw = dict([[t.strip() for t in l.split(':', 1)]
168 kw = dict([[t.strip() for t in l.split(':', 1)]
168 for l in open('.hg_archival.txt')])
169 for l in open('.hg_archival.txt')])
169 if 'tag' in kw:
170 if 'tag' in kw:
170 version = kw['tag']
171 version = kw['tag']
171 elif 'latesttag' in kw:
172 elif 'latesttag' in kw:
172 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
173 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
173 else:
174 else:
174 version = kw.get('node', '')[:12]
175 version = kw.get('node', '')[:12]
175
176
176 if version:
177 if version:
177 f = open("mercurial/__version__.py", "w")
178 f = open("mercurial/__version__.py", "w")
178 f.write('# this file is autogenerated by setup.py\n')
179 f.write('# this file is autogenerated by setup.py\n')
179 f.write('version = "%s"\n' % version)
180 f.write('version = "%s"\n' % version)
180 f.close()
181 f.close()
181
182
182
183
183 try:
184 try:
184 from mercurial import __version__
185 from mercurial import __version__
185 version = __version__.version
186 version = __version__.version
186 except ImportError:
187 except ImportError:
187 version = 'unknown'
188 version = 'unknown'
188
189
189 class hgbuildmo(build):
190 class hgbuildmo(build):
190
191
191 description = "build translations (.mo files)"
192 description = "build translations (.mo files)"
192
193
193 def run(self):
194 def run(self):
194 if not find_executable('msgfmt'):
195 if not find_executable('msgfmt'):
195 self.warn("could not find msgfmt executable, no translations "
196 self.warn("could not find msgfmt executable, no translations "
196 "will be built")
197 "will be built")
197 return
198 return
198
199
199 podir = 'i18n'
200 podir = 'i18n'
200 if not os.path.isdir(podir):
201 if not os.path.isdir(podir):
201 self.warn("could not find %s/ directory" % podir)
202 self.warn("could not find %s/ directory" % podir)
202 return
203 return
203
204
204 join = os.path.join
205 join = os.path.join
205 for po in os.listdir(podir):
206 for po in os.listdir(podir):
206 if not po.endswith('.po'):
207 if not po.endswith('.po'):
207 continue
208 continue
208 pofile = join(podir, po)
209 pofile = join(podir, po)
209 modir = join('locale', po[:-3], 'LC_MESSAGES')
210 modir = join('locale', po[:-3], 'LC_MESSAGES')
210 mofile = join(modir, 'hg.mo')
211 mofile = join(modir, 'hg.mo')
211 mobuildfile = join('mercurial', mofile)
212 mobuildfile = join('mercurial', mofile)
212 cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile]
213 cmd = ['msgfmt', '-v', '-o', mobuildfile, pofile]
213 if sys.platform != 'sunos5':
214 if sys.platform != 'sunos5':
214 # msgfmt on Solaris does not know about -c
215 # msgfmt on Solaris does not know about -c
215 cmd.append('-c')
216 cmd.append('-c')
216 self.mkpath(join('mercurial', modir))
217 self.mkpath(join('mercurial', modir))
217 self.make_file([pofile], mobuildfile, spawn, (cmd,))
218 self.make_file([pofile], mobuildfile, spawn, (cmd,))
218
219
220
219 # Insert hgbuildmo first so that files in mercurial/locale/ are found
221 # Insert hgbuildmo first so that files in mercurial/locale/ are found
220 # when build_py is run next.
222 # when build_py is run next.
221 build.sub_commands.insert(0, ('build_mo', None))
223 build.sub_commands.insert(0, ('build_mo', None))
222
224
223 Distribution.pure = 0
225 Distribution.pure = 0
224 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
226 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
225 "code instead of C extensions"))
227 "code instead of C extensions"))
226
228
227 class hgbuildext(build_ext):
229 class hgbuildext(build_ext):
228
230
229 def build_extension(self, ext):
231 def build_extension(self, ext):
230 try:
232 try:
231 build_ext.build_extension(self, ext)
233 build_ext.build_extension(self, ext)
232 except CCompilerError:
234 except CCompilerError:
233 if not getattr(ext, 'optional', False):
235 if not getattr(ext, 'optional', False):
234 raise
236 raise
235 log.warn("Failed to build optional extension '%s' (skipping)",
237 log.warn("Failed to build optional extension '%s' (skipping)",
236 ext.name)
238 ext.name)
237
239
238 class hgbuildpy(build_py):
240 class hgbuildpy(build_py):
239
241
240 def finalize_options(self):
242 def finalize_options(self):
241 build_py.finalize_options(self)
243 build_py.finalize_options(self)
242
244
243 if self.distribution.pure:
245 if self.distribution.pure:
244 if self.py_modules is None:
246 if self.py_modules is None:
245 self.py_modules = []
247 self.py_modules = []
246 for ext in self.distribution.ext_modules:
248 for ext in self.distribution.ext_modules:
247 if ext.name.startswith("mercurial."):
249 if ext.name.startswith("mercurial."):
248 self.py_modules.append("mercurial.pure.%s" % ext.name[10:])
250 self.py_modules.append("mercurial.pure.%s" % ext.name[10:])
249 self.distribution.ext_modules = []
251 self.distribution.ext_modules = []
250 else:
252 else:
251 if not os.path.exists(os.path.join(get_python_inc(), 'Python.h')):
253 if not os.path.exists(os.path.join(get_python_inc(), 'Python.h')):
252 raise SystemExit("Python headers are required to build Mercurial")
254 raise SystemExit("Python headers are required to build Mercurial")
253
255
254 def find_modules(self):
256 def find_modules(self):
255 modules = build_py.find_modules(self)
257 modules = build_py.find_modules(self)
256 for module in modules:
258 for module in modules:
257 if module[0] == "mercurial.pure":
259 if module[0] == "mercurial.pure":
258 if module[1] != "__init__":
260 if module[1] != "__init__":
259 yield ("mercurial", module[1], module[2])
261 yield ("mercurial", module[1], module[2])
260 else:
262 else:
261 yield module
263 yield module
262
264
265 class hginstallscripts(install_scripts):
266 '''
267 This is a specialization of install_scripts that replaces the @LIBDIR@ with
268 the configured directory for modules. If possible, the path is made relative
269 to the directory for scripts.
270 '''
271
272 def initialize_options(self):
273 install_scripts.initialize_options(self)
274
275 self.install_lib = None
276
277 def finalize_options(self):
278 install_scripts.finalize_options(self)
279 self.set_undefined_options('install',
280 ('install_lib', 'install_lib'))
281
282 def run(self):
283 install_scripts.run(self)
284
285 if (os.path.splitdrive(self.install_dir)[0] !=
286 os.path.splitdrive(self.install_lib)[0]):
287 # can't make relative paths from one drive to another, so use an
288 # absolute path instead
289 libdir = self.install_lib
290 else:
291 common = os.path.commonprefix((self.install_dir, self.install_lib))
292 rest = self.install_dir[len(common):]
293 uplevel = len([n for n in os.path.split(rest) if n])
294
295 libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):]
296
297 for outfile in self.outfiles:
298 data = open(outfile, 'rb').read()
299
300 # skip binary files
301 if '\0' in data:
302 continue
303
304 data = data.replace('@LIBDIR@', libdir)
305 open(outfile, 'wb').write(data)
306
263 cmdclass = {'build_mo': hgbuildmo,
307 cmdclass = {'build_mo': hgbuildmo,
264 'build_ext': hgbuildext,
308 'build_ext': hgbuildext,
265 'build_py': hgbuildpy}
309 'build_py': hgbuildpy,
310 'install_scripts': hginstallscripts}
266
311
267 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
312 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
268 'hgext.highlight', 'hgext.zeroconf']
313 'hgext.highlight', 'hgext.zeroconf']
269
314
270 pymodules = []
315 pymodules = []
271
316
272 extmodules = [
317 extmodules = [
273 Extension('mercurial.base85', ['mercurial/base85.c']),
318 Extension('mercurial.base85', ['mercurial/base85.c']),
274 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
319 Extension('mercurial.bdiff', ['mercurial/bdiff.c']),
275 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
320 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']),
276 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
321 Extension('mercurial.mpatch', ['mercurial/mpatch.c']),
277 Extension('mercurial.parsers', ['mercurial/parsers.c']),
322 Extension('mercurial.parsers', ['mercurial/parsers.c']),
278 ]
323 ]
279
324
280 # disable osutil.c under windows + python 2.4 (issue1364)
325 # disable osutil.c under windows + python 2.4 (issue1364)
281 if sys.platform == 'win32' and sys.version_info < (2, 5, 0, 'final'):
326 if sys.platform == 'win32' and sys.version_info < (2, 5, 0, 'final'):
282 pymodules.append('mercurial.pure.osutil')
327 pymodules.append('mercurial.pure.osutil')
283 else:
328 else:
284 extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
329 extmodules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
285
330
286 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
331 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
287 # The inotify extension is only usable with Linux 2.6 kernels.
332 # The inotify extension is only usable with Linux 2.6 kernels.
288 # You also need a reasonably recent C library.
333 # You also need a reasonably recent C library.
289 # In any case, if it fails to build the error will be skipped ('optional').
334 # In any case, if it fails to build the error will be skipped ('optional').
290 cc = new_compiler()
335 cc = new_compiler()
291 if hasfunction(cc, 'inotify_add_watch'):
336 if hasfunction(cc, 'inotify_add_watch'):
292 inotify = Extension('hgext.inotify.linux._inotify',
337 inotify = Extension('hgext.inotify.linux._inotify',
293 ['hgext/inotify/linux/_inotify.c'],
338 ['hgext/inotify/linux/_inotify.c'],
294 ['mercurial'])
339 ['mercurial'])
295 inotify.optional = True
340 inotify.optional = True
296 extmodules.append(inotify)
341 extmodules.append(inotify)
297 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
342 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
298
343
299 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
344 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
300 'help/*.txt']}
345 'help/*.txt']}
301
346
302 def ordinarypath(p):
347 def ordinarypath(p):
303 return p and p[0] != '.' and p[-1] != '~'
348 return p and p[0] != '.' and p[-1] != '~'
304
349
305 for root in ('templates',):
350 for root in ('templates',):
306 for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
351 for curdir, dirs, files in os.walk(os.path.join('mercurial', root)):
307 curdir = curdir.split(os.sep, 1)[1]
352 curdir = curdir.split(os.sep, 1)[1]
308 dirs[:] = filter(ordinarypath, dirs)
353 dirs[:] = filter(ordinarypath, dirs)
309 for f in filter(ordinarypath, files):
354 for f in filter(ordinarypath, files):
310 f = os.path.join(curdir, f)
355 f = os.path.join(curdir, f)
311 packagedata['mercurial'].append(f)
356 packagedata['mercurial'].append(f)
312
357
313 datafiles = []
358 datafiles = []
314 setupversion = version
359 setupversion = version
315 extra = {}
360 extra = {}
316
361
317 if py2exeloaded:
362 if py2exeloaded:
318 extra['console'] = [
363 extra['console'] = [
319 {'script':'hg',
364 {'script':'hg',
320 'copyright':'Copyright (C) 2005-2010 Matt Mackall and others',
365 'copyright':'Copyright (C) 2005-2010 Matt Mackall and others',
321 'product_version':version}]
366 'product_version':version}]
322
367
323 if os.name == 'nt':
368 if os.name == 'nt':
324 # Windows binary file versions for exe/dll files must have the
369 # Windows binary file versions for exe/dll files must have the
325 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
370 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
326 setupversion = version.split('+', 1)[0]
371 setupversion = version.split('+', 1)[0]
327
372
328 setup(name='mercurial',
373 setup(name='mercurial',
329 version=setupversion,
374 version=setupversion,
330 author='Matt Mackall',
375 author='Matt Mackall',
331 author_email='mpm@selenic.com',
376 author_email='mpm@selenic.com',
332 url='http://mercurial.selenic.com/',
377 url='http://mercurial.selenic.com/',
333 description='Scalable distributed SCM',
378 description='Scalable distributed SCM',
334 license='GNU GPLv2+',
379 license='GNU GPLv2+',
335 scripts=scripts,
380 scripts=scripts,
336 packages=packages,
381 packages=packages,
337 py_modules=pymodules,
382 py_modules=pymodules,
338 ext_modules=extmodules,
383 ext_modules=extmodules,
339 data_files=datafiles,
384 data_files=datafiles,
340 package_data=packagedata,
385 package_data=packagedata,
341 cmdclass=cmdclass,
386 cmdclass=cmdclass,
342 options=dict(py2exe=dict(packages=['hgext', 'email']),
387 options=dict(py2exe=dict(packages=['hgext', 'email']),
343 bdist_mpkg=dict(zipdist=True,
388 bdist_mpkg=dict(zipdist=True,
344 license='COPYING',
389 license='COPYING',
345 readme='contrib/macosx/Readme.html',
390 readme='contrib/macosx/Readme.html',
346 welcome='contrib/macosx/Welcome.html')),
391 welcome='contrib/macosx/Welcome.html')),
347 **extra)
392 **extra)
General Comments 0
You need to be logged in to leave comments. Login now