[PATCH] build: allow some python variable overrides

Paul Kölle pkoelle at gmail.com
Tue Feb 4 09:39:34 MST 2014


Am 04.02.2014 11:17, schrieb Gustavo Zacarias:
> On 02/03/2014 03:45 PM, Paul Kölle wrote:
>
>> Hi Zacarias,
>>
>> I think the code could use some stylistic improvements if you dont mind ;)
>
> Of course, it's welcome, my python-fu isn't great.
>
>> Don't use bare except statements, this should probably be "except
>> KeyError" but you might want to avoid all those try/except lines
>> altogether. Why not use something like:
>>
>> os_env = dict(os.environ)
>>
>> if os_env.get('python_LDFLAGS', None):
>>    conf.log.write("python_LDFLAGS override from environment = %r\n" %
>>                   (override_python_LDFLAGS))
>>    python_LDFLAGS = override_python_LDFLAGS
>>
>> cheers
>>   Paul
>
> True about the blind except.
> There's a little problem there with your way... if i do...
> python_LDFLAGS="" then it's assuming it's not overriding, when it is
> (and there are valid use-cases for it being empty, in fact it works
> better if left empty when cross-compiling and let python-config provide
> it's stuff alone).
> Regards.
>
Hi Zacarias,

Ah, so "" ->(empty string) is a valid override from os_env? The 
canonical fix would be to test for identity not equality (is not None):

os_env = dict(os.environ)
override_python_LDFLAGS = os_env.get('python_LDFLAGS', None)

if override_python_LDFLAGS is not None:
    conf.log.write("python_LDFLAGS override from environment = %r\n" %
                   (override_python_LDFLAGS))
    python_LDFLAGS = override_python_LDFLAGS

hth
  Paul



More information about the samba-technical mailing list