diff setup.py @ 16187:82ce91a9fd94 stable

setup: handle output from Apple's Xcode 4.3 better (issue3277) Apparently, it prints nothing at all if the user installed only the command-line tools. In that case, don't try to parse the empty output -- just assume they have Xcode >= 4.
author Greg Ward <greg@gerg.ca>
date Mon, 27 Feb 2012 08:54:26 -0500
parents 9926aab3d0b5
children 5536770b3c88
line wrap: on
line diff
--- a/setup.py	Sat Feb 18 16:30:17 2012 -0500
+++ b/setup.py	Mon Feb 27 08:54:26 2012 -0500
@@ -452,10 +452,18 @@
 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()[0]
-    # Also parse only first digit, because 3.2.1 can't be parsed nicely
-    if (version.startswith('Xcode') and
-        StrictVersion(version.split()[1]) >= StrictVersion('4.0')):
+    version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines()
+    if version:
+        version = version.splitlines()[0]
+        xcode4 = (version.startswith('Xcode') and
+                  StrictVersion(version.split()[1]) >= StrictVersion('4.0'))
+    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
+
+    if xcode4:
         os.environ['ARCHFLAGS'] = ''
 
 setup(name='mercurial',