From 39202f5ac043ae9291cc0e830ad8597f49064700 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Thu, 30 Jan 2020 15:15:14 +0100 Subject: [PATCH] mapnik-config: fix substitution of environment variables Simply calling str(val) doesn't work, because if the value happens to be a SCons.Util.CLVar, it may contain not just plain strings, but also tuples appended by SCons.Environment.ParseFlags. For example "-isysroot /foo" becomes CLVar: [("-isysroot", "/foo")] CLVar.__str__ supports only string elements, nothing else. --- utils/mapnik-config/build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/mapnik-config/build.py b/utils/mapnik-config/build.py index 10305302c..53fab58e7 100644 --- a/utils/mapnik-config/build.py +++ b/utils/mapnik-config/build.py @@ -59,11 +59,11 @@ def write_config(env, template_filename, config_filename): escape = env['ESCAPE'] def subst(matchobj): key = matchobj.group(1) - val = env.get(key) - if val is None: + if key not in env: return matchobj.group(0) else: - return 'CONFIG_%s=%s' % (key, escape(str(val))) + val = env.subst('$' + key) + return 'CONFIG_%s=%s' % (key, escape(val)) config = re.sub(r'^CONFIG_(\w+)=.*', subst, template, flags=re.M) config_file.write(config) try: