summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-06-17 13:47:42 -0700
committerGary E. Miller <gem@rellim.com>2018-06-17 13:47:42 -0700
commit851cc68d8d5194d4f5ff799aafedefbb7de76492 (patch)
treeb8ca84976545a3fe48570dda7763ce515766fee5 /SConstruct
parent62cba3f59855e0ad374ab1e97eb8669c999a18a8 (diff)
downloadgpsd-851cc68d8d5194d4f5ff799aafedefbb7de76492.tar.gz
SConstruct: fix 'scons clean' for Python 3.
gpsd will now build, install and check, when the system Python is version 3. At least for me...
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct14
1 files changed, 12 insertions, 2 deletions
diff --git a/SConstruct b/SConstruct
index a0bffdce..e337b8a9 100644
--- a/SConstruct
+++ b/SConstruct
@@ -998,9 +998,19 @@ else:
PYTHON_CONFIG_CALL,
brief=True)
+
+# ugly hack from http://www.catb.org/esr/faqs/practical-python-porting/
+# handle python2/3 strings
+def polystr(o):
+ if isinstance(o, str):
+ return o
+ if isinstance(o, bytes):
+ return str(o, encoding='latin-1')
+ raise ValueError
+
if env['python']: # May have been turned off by error
- env['PYTHON'] = target_python_path
- env['ENV']['PYTHON'] = target_python_path # For regress-driver
+ env['PYTHON'] = polystr(target_python_path)
+ env['ENV']['PYTHON'] = polystr(target_python_path) # For regress-driver
py_config_vars = ast.literal_eval(py_config_text.decode())
py_config_vars = [[] if x is None else x for x in py_config_vars]
python_config = dict(zip(PYTHON_CONFIG_NAMES, py_config_vars))