diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-09-11 01:31:21 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-09-11 01:31:21 +0100 |
| commit | 1d6bbdf6298eab4d323fc3e8409d64712646db52 (patch) | |
| tree | 62da0d37e4f6d96b67b41239f0df4812488b55aa /wscript | |
| parent | 08d3a8410d7dc106ce9b5786de99d38ee44e00ee (diff) | |
Fix build on Centos.
Diffstat (limited to 'wscript')
| -rw-r--r-- | wscript | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -6,6 +6,45 @@ APPNAME = 'libsub' VERSION = '1.2.4devel' API_VERSION = '-1.0' +try: + from subprocess import STDOUT, check_output, CalledProcessError +except ImportError: + # python 2.6 (in Centos 6) doesn't include check_output + # monkey patch it in! + import subprocess + STDOUT = subprocess.STDOUT + + def check_output(*popenargs, **kwargs): + if 'stdout' in kwargs: # pragma: no cover + raise ValueError('stdout argument not allowed, ' + 'it will be overridden.') + process = subprocess.Popen(stdout=subprocess.PIPE, + *popenargs, **kwargs) + output, _ = process.communicate() + retcode = process.poll() + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + raise subprocess.CalledProcessError(retcode, cmd, + output=output) + return output + subprocess.check_output = check_output + + # overwrite CalledProcessError due to `output` + # keyword not being available (in 2.6) + class CalledProcessError(Exception): + + def __init__(self, returncode, cmd, output=None): + self.returncode = returncode + self.cmd = cmd + self.output = output + + def __str__(self): + return "Command '%s' returned non-zero exit status %d" % ( + self.cmd, self.returncode) + subprocess.CalledProcessError = CalledProcessError + def options(opt): opt.load('compiler_cxx') opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation') |
