comparison setup.py @ 21038:440fbe52b4a8

setup.py: fix C extension compilation issue with OS X 10.9 and Xcode 5.1
author Kent Frazier <kentfrazier@gmail.com>
date Tue, 15 Apr 2014 16:27:12 -0400
parents 1cd5bff45db2
children 54d7657d7d1e
comparison
equal deleted inserted replaced
21037:b775a2029e8d 21038:440fbe52b4a8
59 except ImportError: 59 except ImportError:
60 raise SystemExit( 60 raise SystemExit(
61 "Couldn't import standard bz2 (incomplete Python install).") 61 "Couldn't import standard bz2 (incomplete Python install).")
62 62
63 import os, subprocess, time 63 import os, subprocess, time
64 import re
64 import shutil 65 import shutil
65 import tempfile 66 import tempfile
66 from distutils import log 67 from distutils import log
67 from distutils.core import setup, Command, Extension 68 from distutils.core import setup, Command, Extension
68 from distutils.dist import Distribution 69 from distutils.dist import Distribution
71 from distutils.command.build_py import build_py 72 from distutils.command.build_py import build_py
72 from distutils.command.install_scripts import install_scripts 73 from distutils.command.install_scripts import install_scripts
73 from distutils.spawn import spawn, find_executable 74 from distutils.spawn import spawn, find_executable
74 from distutils import cygwinccompiler 75 from distutils import cygwinccompiler
75 from distutils.errors import CCompilerError, DistutilsExecError 76 from distutils.errors import CCompilerError, DistutilsExecError
76 from distutils.sysconfig import get_python_inc 77 from distutils.sysconfig import get_python_inc, get_config_var
77 from distutils.version import StrictVersion 78 from distutils.version import StrictVersion
78 79
79 convert2to3 = '--c2to3' in sys.argv 80 convert2to3 = '--c2to3' in sys.argv
80 if convert2to3: 81 if convert2to3:
81 try: 82 try:
503 # Windows binary file versions for exe/dll files must have the 504 # Windows binary file versions for exe/dll files must have the
504 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 505 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
505 setupversion = version.split('+', 1)[0] 506 setupversion = version.split('+', 1)[0]
506 507
507 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): 508 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
508 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
509 # distutils.sysconfig
510 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines() 509 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines()
511 if version: 510 if version:
512 version = version[0] 511 version = version[0]
513 xcode4 = (version.startswith('Xcode') and 512 xcode4 = (version.startswith('Xcode') and
514 StrictVersion(version.split()[1]) >= StrictVersion('4.0')) 513 StrictVersion(version.split()[1]) >= StrictVersion('4.0'))
514 xcode51 = re.match(r'^Xcode\s+5\.1\.', version) is not None
515 else: 515 else:
516 # xcodebuild returns empty on OS X Lion with XCode 4.3 not 516 # xcodebuild returns empty on OS X Lion with XCode 4.3 not
517 # installed, but instead with only command-line tools. Assume 517 # installed, but instead with only command-line tools. Assume
518 # that only happens on >= Lion, thus no PPC support. 518 # that only happens on >= Lion, thus no PPC support.
519 xcode4 = True 519 xcode4 = True
520 520 xcode51 = False
521
522 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
523 # distutils.sysconfig
521 if xcode4: 524 if xcode4:
522 os.environ['ARCHFLAGS'] = '' 525 os.environ['ARCHFLAGS'] = ''
526
527 # XCode 5.1 changes clang such that it now fails to compile if the
528 # -mno-fused-madd flag is passed, but the version of Python shipped with
529 # OS X 10.9 Mavericks includes this flag. This causes problems in all
530 # C extension modules, and a bug has been filed upstream at
531 # http://bugs.python.org/issue21244. We also need to patch this here
532 # so Mercurial can continue to compile in the meantime.
533 if xcode51:
534 cflags = get_config_var('CFLAGS')
535 if re.search(r'-mno-fused-madd\b', cflags) is not None:
536 os.environ['CFLAGS'] = (
537 os.environ.get('CFLAGS', '') + ' -Qunused-arguments')
523 538
524 setup(name='mercurial', 539 setup(name='mercurial',
525 version=setupversion, 540 version=setupversion,
526 author='Matt Mackall and many others', 541 author='Matt Mackall and many others',
527 author_email='mercurial@selenic.com', 542 author_email='mercurial@selenic.com',