changeset 13636:4bfff063aed6 stable

setup: fix mac build broken by e42d18538e1d Sometimes xcodebuild prints warnings to stderr, but runcmd() assumes anything printed to stderr implies failure. Since runcmd() was originally only intended to run hg, this was fine until it was pressed into service for running xcodebuild. Thus: split runcmd() into two parts: runcmd(), which does the minimal amount of work to run a subprocess, and runhg(), which calls runcmd().
author Jon M. Dugan <jdugan@x1024.net>
date Sun, 13 Mar 2011 17:39:33 -0500
parents c9ddc39c21b6
children 4e976235c985 2420cb1ea1d6
files setup.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Mon Mar 14 13:54:25 2011 +0100
+++ b/setup.py	Sun Mar 13 17:39:33 2011 -0500
@@ -121,6 +121,10 @@
     p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE, env=env)
     out, err = p.communicate()
+    return out, err
+
+def runhg(cmd, env):
+    out, err = runcmd(cmd, env)
     # If root is executing setup.py, but the repository is owned by
     # another user (as in "sudo python setup.py install") we will get
     # trust warnings since the .hg/hgrc file is untrusted. That is
@@ -151,7 +155,7 @@
         # error 0xc0150004. See: http://bugs.python.org/issue3440
         env['SystemRoot'] = os.environ['SystemRoot']
     cmd = [sys.executable, 'hg', 'id', '-i', '-t']
-    l = runcmd(cmd, env).split()
+    l = runhg(cmd, env).split()
     while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
         l.pop()
     if len(l) > 1: # tag found
@@ -161,7 +165,7 @@
     elif len(l) == 1: # no tag found
         cmd = [sys.executable, 'hg', 'parents', '--template',
                '{latesttag}+{latesttagdistance}-']
-        version = runcmd(cmd, env) + l[0]
+        version = runhg(cmd, env) + l[0]
     if version.endswith('+'):
         version += time.strftime('%Y%m%d')
 elif os.path.exists('.hg_archival.txt'):
@@ -377,7 +381,7 @@
 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'], {}).splitlines()[0]
+    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')):