42 if os.name == 'nt': |
42 if os.name == 'nt': |
43 scripts.append('contrib/win32/hg.bat') |
43 scripts.append('contrib/win32/hg.bat') |
44 |
44 |
45 # simplified version of distutils.ccompiler.CCompiler.has_function |
45 # simplified version of distutils.ccompiler.CCompiler.has_function |
46 # that actually removes its temporary files. |
46 # that actually removes its temporary files. |
47 def has_function(cc, funcname): |
47 def hasfunction(cc, funcname): |
48 tmpdir = tempfile.mkdtemp(prefix='hg-install-') |
48 tmpdir = tempfile.mkdtemp(prefix='hg-install-') |
49 devnull = oldstderr = None |
49 devnull = oldstderr = None |
50 try: |
50 try: |
51 try: |
51 try: |
52 fname = os.path.join(tmpdir, 'funcname.c') |
52 fname = os.path.join(tmpdir, 'funcname.c') |
163 from mercurial import __version__ |
163 from mercurial import __version__ |
164 version = __version__.version |
164 version = __version__.version |
165 except ImportError: |
165 except ImportError: |
166 version = 'unknown' |
166 version = 'unknown' |
167 |
167 |
168 class build_mo(build): |
168 class hgbuildmo(build): |
169 |
169 |
170 description = "build translations (.mo files)" |
170 description = "build translations (.mo files)" |
171 |
171 |
172 def run(self): |
172 def run(self): |
173 if not find_executable('msgfmt'): |
173 if not find_executable('msgfmt'): |
193 # msgfmt on Solaris does not know about -c |
193 # msgfmt on Solaris does not know about -c |
194 cmd.append('-c') |
194 cmd.append('-c') |
195 self.mkpath(join('mercurial', modir)) |
195 self.mkpath(join('mercurial', modir)) |
196 self.make_file([pofile], mobuildfile, spawn, (cmd,)) |
196 self.make_file([pofile], mobuildfile, spawn, (cmd,)) |
197 |
197 |
198 # Insert build_mo first so that files in mercurial/locale/ are found |
198 # Insert hgbuildmo first so that files in mercurial/locale/ are found |
199 # when build_py is run next. |
199 # when build_py is run next. |
200 build.sub_commands.insert(0, ('build_mo', None)) |
200 build.sub_commands.insert(0, ('build_mo', None)) |
201 |
201 |
202 Distribution.pure = 0 |
202 Distribution.pure = 0 |
203 Distribution.global_options.append(('pure', None, "use pure (slow) Python " |
203 Distribution.global_options.append(('pure', None, "use pure (slow) Python " |
204 "code instead of C extensions")) |
204 "code instead of C extensions")) |
205 |
205 |
206 class hg_build_py(build_py): |
206 class hgbuildpy(build_py): |
207 |
207 |
208 def finalize_options(self): |
208 def finalize_options(self): |
209 build_py.finalize_options(self) |
209 build_py.finalize_options(self) |
210 |
210 |
211 if self.distribution.pure: |
211 if self.distribution.pure: |
223 if module[1] != "__init__": |
223 if module[1] != "__init__": |
224 yield ("mercurial", module[1], module[2]) |
224 yield ("mercurial", module[1], module[2]) |
225 else: |
225 else: |
226 yield module |
226 yield module |
227 |
227 |
228 cmdclass = {'build_mo': build_mo, |
228 cmdclass = {'build_mo': hgbuildmo, |
229 'build_py': hg_build_py} |
229 'build_py': hgbuildpy} |
230 |
230 |
231 ext_modules=[ |
231 extmodules = [ |
232 Extension('mercurial.base85', ['mercurial/base85.c']), |
232 Extension('mercurial.base85', ['mercurial/base85.c']), |
233 Extension('mercurial.bdiff', ['mercurial/bdiff.c']), |
233 Extension('mercurial.bdiff', ['mercurial/bdiff.c']), |
234 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']), |
234 Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']), |
235 Extension('mercurial.mpatch', ['mercurial/mpatch.c']), |
235 Extension('mercurial.mpatch', ['mercurial/mpatch.c']), |
236 Extension('mercurial.parsers', ['mercurial/parsers.c']), |
236 Extension('mercurial.parsers', ['mercurial/parsers.c']), |
242 |
242 |
243 if sys.platform == 'linux2' and os.uname()[2] > '2.6': |
243 if sys.platform == 'linux2' and os.uname()[2] > '2.6': |
244 # The inotify extension is only usable with Linux 2.6 kernels. |
244 # The inotify extension is only usable with Linux 2.6 kernels. |
245 # You also need a reasonably recent C library. |
245 # You also need a reasonably recent C library. |
246 cc = new_compiler() |
246 cc = new_compiler() |
247 if has_function(cc, 'inotify_add_watch'): |
247 if hasfunction(cc, 'inotify_add_watch'): |
248 ext_modules.append(Extension('hgext.inotify.linux._inotify', |
248 extmodules.append(Extension('hgext.inotify.linux._inotify', |
249 ['hgext/inotify/linux/_inotify.c'])) |
249 ['hgext/inotify/linux/_inotify.c'])) |
250 packages.extend(['hgext.inotify', 'hgext.inotify.linux']) |
250 packages.extend(['hgext.inotify', 'hgext.inotify.linux']) |
251 |
251 |
252 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', |
252 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', |
253 'help/*.txt']} |
253 'help/*.txt']} |
272 url='http://mercurial.selenic.com/', |
272 url='http://mercurial.selenic.com/', |
273 description='Scalable distributed SCM', |
273 description='Scalable distributed SCM', |
274 license='GNU GPL', |
274 license='GNU GPL', |
275 scripts=scripts, |
275 scripts=scripts, |
276 packages=packages, |
276 packages=packages, |
277 ext_modules=ext_modules, |
277 ext_modules=extmodules, |
278 data_files=datafiles, |
278 data_files=datafiles, |
279 package_data=packagedata, |
279 package_data=packagedata, |
280 cmdclass=cmdclass, |
280 cmdclass=cmdclass, |
281 options=dict(py2exe=dict(packages=['hgext', 'email']), |
281 options=dict(py2exe=dict(packages=['hgext', 'email']), |
282 bdist_mpkg=dict(zipdist=True, |
282 bdist_mpkg=dict(zipdist=True, |