[PATCH 1 of 2] setup: fix f51d1822d6fd refactoring, propagate env to runcmd

Christian Boos cboos at neuf.fr
Mon Nov 9 15:27:33 CST 2009


Gilles Moris wrote:
> On Monday 09 November 2009 06:33:09 pm Christian Boos wrote:
>   
>> # HG changeset patch
>> # User Christian Boos <cboos at bct-technology.com>
>> # Date 1257784396 -3600
>> # Node ID 3e114d36f982e11696b359a408f69f6a45b6e071
>> # Parent  4ce13d7c6b8855e028dd284e03d416400fcb5225
>> setup: fix f51d1822d6fd refactoring, propagate env to runcmd
>>
>> diff -r 4ce13d7c6b88 -r 3e114d36f982 setup.py
>> --- a/setup.py	Sun Nov 08 18:50:39 2009 +0100
>> +++ b/setup.py	Mon Nov 09 17:33:16 2009 +0100
>> @@ -97,7 +97,7 @@
>>  except ImportError:
>>      pass
>>
>> -def runcmd(cmd):
>> +def runcmd(cmd, env):
>>      p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
>>                           stderr=subprocess.PIPE, env=env)
>>      out, err = p.communicate()
>> @@ -127,7 +127,7 @@
>>          # error 0xc0150004. See: http://bugs.python.org/issue3440
>>          env['SystemRoot'] = os.environ['SystemRoot']
>>      cmd = [sys.executable, 'hg', 'id', '-i', '-t']
>> -    l = runcmd(cmd).split()
>> +    l = runcmd(cmd, env).split()
>>      while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
>>          l.pop()
>>      if len(l) > 1: # tag found
>> @@ -137,7 +137,7 @@
>>      elif len(l) == 1: # no tag found
>>          cmd = [sys.executable, 'hg', 'parents', '--template',
>>                 '{latesttag}+{latesttagdistance}-']
>> -        version = runcmd(cmd) + l[0]
>> +        version = runcmd(cmd, env) + l[0]
>>      if version.endswith('+'):
>>          version += time.strftime('%Y%m%d')
>>  elif os.path.exists('.hg_archival.txt'):
>>     
>
> Nice catch ! I think it's safe to apply.
>
> However, env is correctly bound on my side, as it seems to fallback to the 
> global scope. Do you have a NameError exception ? May be python 2.4 specific.
>   

No, I didn't have a NameError actually, env was effectively obtained 
from the global scope.
But well, it just feels cleaner that way, not passing env via global 
scope...

What was effectively preventing the generation of the version for me was 
the LD_LIBRARY_PATH problem I fixed with the second patch (I just 
verified it was enough).

-- Christian


More information about the Mercurial-devel mailing list