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