From: "Gary E. Miller" Date: Wed, 8 Jan 2020 17:25:16 -0800 Subject: [PATCH] SConstruct: Fix GetPythonValue() for python 3. --- SConstruct | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index fc5ab39bfad6..a5c41e8f4803 100644 --- a/SConstruct +++ b/SConstruct @@ -604,7 +604,8 @@ def GetPythonValue(context, name, imp, expr, brief=False): context.sconf.cached = 0 # Avoid bogus "(cached)" if not context.env['target_python']: - status, value = 0, str(eval(expr)) + status = 0 + value = str(eval(expr)) else: command = [target_python_path, '-c', '%s; print(%s)' % (imp, expr)] try: @@ -619,7 +620,14 @@ def GetPythonValue(context, name, imp, expr, brief=False): 'Python components will NOT be installed' % command[2]) context.env['python'] = False - context.Result('failed' if status else 'ok' if brief else value) + if 0 != status: + result = 'failed' + elif brief: + result = 'ok' + else: + # context.Result() confused by bytes + result = polystr(value) + context.Result(result) return value @@ -1181,15 +1189,14 @@ elif config.env['python']: # Maximize consistency by using the reported sys.executable target_python_path = config.GetPythonValue('exe path', 'import sys', - 'sys.executable', - brief=cleaning) + 'sys.executable') + # python module directory if config.env['python_libdir']: python_libdir = config.env['python_libdir'] else: python_libdir = config.GetPythonValue('lib dir', PYTHON_SYSCONFIG_IMPORT, - PYTHON_LIBDIR_CALL, - brief=cleaning) + PYTHON_LIBDIR_CALL) # follow FHS, put in /usr/local/libXX, not /usr/libXX # may be lib, lib32 or lib64 python_libdir = polystr(python_libdir)