gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH] Adds fallback for target_python handling with older s


From: Fred Wright
Subject: [gpsd-dev] [PATCH] Adds fallback for target_python handling with older scons.
Date: Wed, 13 Apr 2016 15:17:07 -0700

The CheckProg function is a relatively recent addition to scons, and
is missing from, e.g., scons 2.3.0.  It's worth using it to simplify
the error case, but fallback code is needed to allow building with a
nonempty target_python option and an older scons.  This fix makes it
work correctly in the non-error case, and also avoids crashing the
build in the common error case, albeit without avoiding duplicate
error messages.

TESTED:
Ran "scons -c" with blank, valid, and invalid target_python values
both on OSX with scons 2.4.1 and Linux with scons 2.3.0.
---
 SConstruct | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/SConstruct b/SConstruct
index f33f5b1..d40a775 100644
--- a/SConstruct
+++ b/SConstruct
@@ -508,11 +508,14 @@ def GetPythonValue(context, name, imp, expr, brief=False):
     else:
         command = [target_python_path, '-c',
                    '%s; print(%s)' % (imp, expr)]
-        status, value = _getstatusoutput(command, shell=False)
+        try:
+            status, value = _getstatusoutput(command, shell=False)
+        except OSError:
+            status = -1
         if status == 0:
             value = value.strip()
         else:
-            value = None
+            value = ''
             announce("Python command failed - disabling Python.")
             env['python'] = False
     context.Result('failed' if status else 'ok' if brief else value)
@@ -879,7 +882,12 @@ if helping:
 else:
 
     if env['python'] and env['target_python']:
-        target_python_path = config.CheckProg(env['target_python'])
+        try:
+            config.CheckProg
+        except AttributeError:  # Older scons versions don't have CheckProg
+            target_python_path = env['target_python']
+        else:
+            target_python_path = config.CheckProg(env['target_python'])
         if not target_python_path:
             announce("Target Python doesn't exist - disabling Python.")
             env['python'] = False
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]