[PATCH] build: allow some python variable overrides

Paul Kölle paul at subsignal.org
Mon Feb 3 11:45:52 MST 2014


Hi Zacarias,

I think the code could use some stylistic improvements if you dont mind ;)

Am 03.02.2014 15:58, schrieb Gustavo Zacarias:
> The python variables (settings) are fetched from a running python
> interpreter which usually isn't the target one when cross compiling,
> hence libraries and flags aren't the same and can pollute the target build.
> Allow some of these variables to be redefined via environment variables
> in order to aid cross-compiling.
> According to testing python_LDFLAGS and python_LIBDIR should be enough.
>
> Signed-off-by: Gustavo Zacarias <gustavo at zacarias.com.ar>
> ---
>   buildtools/wafadmin/Tools/python.py | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/buildtools/wafadmin/Tools/python.py b/buildtools/wafadmin/Tools/python.py
> index ab1e817..e0b8013 100644
> --- a/buildtools/wafadmin/Tools/python.py
> +++ b/buildtools/wafadmin/Tools/python.py
> @@ -193,6 +193,27 @@ MACOSX_DEPLOYMENT_TARGET = %r
>   """ % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS,
>   	python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET))
>
> +	# Allow some python overrides from env vars for cross-compiling
> +	os_env = dict(os.environ)
> +
> +	try:
> +		override_python_LDFLAGS = os_env['python_LDFLAGS']
> +	except:
> +		pass
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

> +
> +	if 'override_python_LDFLAGS' in locals():
> +		conf.log.write("python_LDFLAGS override from environment = %r\n" % (override_python_LDFLAGS))
> +		python_LDFLAGS = override_python_LDFLAGS
> +
> +	try:
> +		override_python_LIBDIR = os_env['python_LIBDIR']
> +	except:
> +		pass
> +
> +	if 'override_python_LIBDIR' in locals():
> +		conf.log.write("python_LIBDIR override from environment = %r\n" % (override_python_LIBDIR))
> +		python_LIBDIR = override_python_LIBDIR
> +
>   	if python_MACOSX_DEPLOYMENT_TARGET:
>   		conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
>   		conf.environ['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
>




More information about the samba-technical mailing list