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