[PATCH] setup: fix mac build broken by e42d18538e1d

Jon M. Dugan jdugan at x1024.net
Sun Mar 13 18:38:00 CDT 2011


# HG changeset patch
# User Jon M. Dugan <jdugan at x1024.net>
# Date 1300055973 18000
# Branch stable
# Node ID 27e8d0c69f6f3cc657885bd4d3fe6e19e39ab791
# Parent  71a96f6c205dcbfbe6a770d11133cc9447f3351b
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().

diff -r 71a96f6c205d -r 27e8d0c69f6f setup.py
--- a/setup.py	Sun Mar 13 14:36:47 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')):


More information about the Mercurial-devel mailing list