comparison setup.py @ 13637:4e976235c985

merge with stable
author Martin Geisler <mg@aragost.com>
date Mon, 14 Mar 2011 14:05:19 +0100
parents fd09c3aeae20 4bfff063aed6
children 16118b4859a1
comparison
equal deleted inserted replaced
13634:15470463f932 13637:4e976235c985
103 103
104 def runcmd(cmd, env): 104 def runcmd(cmd, env):
105 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, 105 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
106 stderr=subprocess.PIPE, env=env) 106 stderr=subprocess.PIPE, env=env)
107 out, err = p.communicate() 107 out, err = p.communicate()
108 return out, err
109
110 def runhg(cmd, env):
111 out, err = runcmd(cmd, env)
108 # If root is executing setup.py, but the repository is owned by 112 # If root is executing setup.py, but the repository is owned by
109 # another user (as in "sudo python setup.py install") we will get 113 # another user (as in "sudo python setup.py install") we will get
110 # trust warnings since the .hg/hgrc file is untrusted. That is 114 # trust warnings since the .hg/hgrc file is untrusted. That is
111 # fine, we don't want to load it anyway. Python may warn about 115 # fine, we don't want to load it anyway. Python may warn about
112 # a missing __init__.py in mercurial/locale, we also ignore that. 116 # a missing __init__.py in mercurial/locale, we also ignore that.
133 # Copy SystemRoot into the custom environment for Python 2.6 137 # Copy SystemRoot into the custom environment for Python 2.6
134 # under Windows. Otherwise, the subprocess will fail with 138 # under Windows. Otherwise, the subprocess will fail with
135 # error 0xc0150004. See: http://bugs.python.org/issue3440 139 # error 0xc0150004. See: http://bugs.python.org/issue3440
136 env['SystemRoot'] = os.environ['SystemRoot'] 140 env['SystemRoot'] = os.environ['SystemRoot']
137 cmd = [sys.executable, 'hg', 'id', '-i', '-t'] 141 cmd = [sys.executable, 'hg', 'id', '-i', '-t']
138 l = runcmd(cmd, env).split() 142 l = runhg(cmd, env).split()
139 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags 143 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
140 l.pop() 144 l.pop()
141 if len(l) > 1: # tag found 145 if len(l) > 1: # tag found
142 version = l[-1] 146 version = l[-1]
143 if l[0].endswith('+'): # propagate the dirty status to the tag 147 if l[0].endswith('+'): # propagate the dirty status to the tag
144 version += '+' 148 version += '+'
145 elif len(l) == 1: # no tag found 149 elif len(l) == 1: # no tag found
146 cmd = [sys.executable, 'hg', 'parents', '--template', 150 cmd = [sys.executable, 'hg', 'parents', '--template',
147 '{latesttag}+{latesttagdistance}-'] 151 '{latesttag}+{latesttagdistance}-']
148 version = runcmd(cmd, env) + l[0] 152 version = runhg(cmd, env) + l[0]
149 if version.endswith('+'): 153 if version.endswith('+'):
150 version += time.strftime('%Y%m%d') 154 version += time.strftime('%Y%m%d')
151 elif os.path.exists('.hg_archival.txt'): 155 elif os.path.exists('.hg_archival.txt'):
152 kw = dict([[t.strip() for t in l.split(':', 1)] 156 kw = dict([[t.strip() for t in l.split(':', 1)]
153 for l in open('.hg_archival.txt')]) 157 for l in open('.hg_archival.txt')])
359 setupversion = version.split('+', 1)[0] 363 setupversion = version.split('+', 1)[0]
360 364
361 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): 365 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
362 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in 366 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
363 # distutils.sysconfig 367 # distutils.sysconfig
364 version = runcmd(['/usr/bin/xcodebuild', '-version'], {}).splitlines()[0] 368 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines()[0]
365 # Also parse only first digit, because 3.2.1 can't be parsed nicely 369 # Also parse only first digit, because 3.2.1 can't be parsed nicely
366 if (version.startswith('Xcode') and 370 if (version.startswith('Xcode') and
367 StrictVersion(version.split()[1]) >= StrictVersion('4.0')): 371 StrictVersion(version.split()[1]) >= StrictVersion('4.0')):
368 os.environ['ARCHFLAGS'] = '-arch i386 -arch x86_64' 372 os.environ['ARCHFLAGS'] = '-arch i386 -arch x86_64'
369 373