Mercurial > public > mercurial-scm > hg-stable
diff setup.py @ 21160:564f55b25122 stable 3.0-rc
merge default into stable for 3.0 code freeze
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 17 Apr 2014 19:36:17 -0400 |
parents | 440fbe52b4a8 |
children | 54d7657d7d1e |
line wrap: on
line diff
--- a/setup.py Tue Apr 15 03:21:59 2014 +0900 +++ b/setup.py Thu Apr 17 19:36:17 2014 -0400 @@ -13,11 +13,18 @@ '''A helper function to emulate 2.6+ bytes literals using string literals.''' return s.encode('latin1') + printf = eval('print') + libdir_escape = 'unicode_escape' else: + libdir_escape = 'string_escape' def b(s): '''A helper function to emulate 2.6+ bytes literals using string literals.''' return s + def printf(*args, **kwargs): + f = kwargs.get('file', sys.stdout) + end = kwargs.get('end', '\n') + f.write(b(' ').join(args) + end) # Solaris Python packaging brain damage try: @@ -54,6 +61,7 @@ "Couldn't import standard bz2 (incomplete Python install).") import os, subprocess, time +import re import shutil import tempfile from distutils import log @@ -64,10 +72,9 @@ from distutils.command.build_py import build_py from distutils.command.install_scripts import install_scripts from distutils.spawn import spawn, find_executable -from distutils.ccompiler import new_compiler from distutils import cygwinccompiler from distutils.errors import CCompilerError, DistutilsExecError -from distutils.sysconfig import get_python_inc +from distutils.sysconfig import get_python_inc, get_config_var from distutils.version import StrictVersion convert2to3 = '--c2to3' in sys.argv @@ -152,8 +159,8 @@ and not e.startswith(b('warning: Not importing')) \ and not e.startswith(b('obsolete feature not enabled'))] if err: - print >> sys.stderr, "stderr from '%s':" % (' '.join(cmd)) - print >> sys.stderr, '\n'.join([' ' + e for e in err]) + printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) + printf(b('\n').join([b(' ') + e for e in err]), file=sys.stderr) return '' return out @@ -403,7 +410,7 @@ if b('\0') in data: continue - data = data.replace('@LIBDIR@', libdir.encode('string_escape')) + data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape)) fp = open(outfile, 'wb') fp.write(data) fp.close() @@ -467,20 +474,6 @@ cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler -if sys.platform.startswith('linux') and os.uname()[2] > '2.6': - # The inotify extension is only usable with Linux 2.6 kernels. - # You also need a reasonably recent C library. - # In any case, if it fails to build the error will be skipped ('optional'). - cc = new_compiler() - if hasfunction(cc, 'inotify_add_watch'): - inotify = Extension('hgext.inotify.linux._inotify', - ['hgext/inotify/linux/_inotify.c'], - ['mercurial'], - depends=common_depends) - inotify.optional = True - extmodules.append(inotify) - packages.extend(['hgext.inotify', 'hgext.inotify.linux']) - packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', 'help/*.txt']} @@ -513,22 +506,36 @@ setupversion = version.split('+', 1)[0] if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): - # XCode 4.0 dropped support for ppc architecture, which is hardcoded in - # distutils.sysconfig version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines() if version: version = version[0] xcode4 = (version.startswith('Xcode') and StrictVersion(version.split()[1]) >= StrictVersion('4.0')) + xcode51 = re.match(r'^Xcode\s+5\.1\.', version) is not None else: # xcodebuild returns empty on OS X Lion with XCode 4.3 not # installed, but instead with only command-line tools. Assume # that only happens on >= Lion, thus no PPC support. xcode4 = True + xcode51 = False + # XCode 4.0 dropped support for ppc architecture, which is hardcoded in + # distutils.sysconfig if xcode4: os.environ['ARCHFLAGS'] = '' + # XCode 5.1 changes clang such that it now fails to compile if the + # -mno-fused-madd flag is passed, but the version of Python shipped with + # OS X 10.9 Mavericks includes this flag. This causes problems in all + # C extension modules, and a bug has been filed upstream at + # http://bugs.python.org/issue21244. We also need to patch this here + # so Mercurial can continue to compile in the meantime. + if xcode51: + cflags = get_config_var('CFLAGS') + if re.search(r'-mno-fused-madd\b', cflags) is not None: + os.environ['CFLAGS'] = ( + os.environ.get('CFLAGS', '') + ' -Qunused-arguments') + setup(name='mercurial', version=setupversion, author='Matt Mackall and many others', @@ -569,9 +576,11 @@ package_data=packagedata, cmdclass=cmdclass, distclass=hgdist, - options=dict(py2exe=dict(packages=['hgext', 'email']), - bdist_mpkg=dict(zipdist=True, - license='COPYING', - readme='contrib/macosx/Readme.html', - welcome='contrib/macosx/Welcome.html')), + options={'py2exe': {'packages': ['hgext', 'email']}, + 'bdist_mpkg': {'zipdist': True, + 'license': 'COPYING', + 'readme': 'contrib/macosx/Readme.html', + 'welcome': 'contrib/macosx/Welcome.html', + }, + }, **extra)