From 2a0664402bae83ece869b1f9f729952df0fb91a0 Mon Sep 17 00:00:00 2001 From: Richard Campbell Date: Thu, 22 Feb 2018 10:23:08 -0600 Subject: RTEMS Docs: Check sphinx version Sphinx.util.compat module was removed at Sphinx version 1.7. Imported module was not being used. Closes #3311. --- common/waf.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'common/waf.py') diff --git a/common/waf.py b/common/waf.py index ed9af48..ae287cb 100644 --- a/common/waf.py +++ b/common/waf.py @@ -81,12 +81,31 @@ class linkcheck(BuildContext): fun = 'cmd_linkcheck' def check_sphinx_version(ctx, minver): - version = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD + - ['--version']).split(" ")[-1:][0].strip() try: - ver = tuple(map(int, re.split('[\D]', version))) + import sphinx + # sphinx.version_info was introduced in sphinx ver 1.2 + version = sphinx.version_info + # version looks like (1, 7, 0, 'final', 0)) + ver = version[0:2] except: - ctx.fatal("Sphinx version cannot be checked: %s" % version) + try: + # sphinx-build returns its version info in stderr + (out, err) = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD + + ['--version'], output=Context.BOTH) + # err looks like 'sphinx-build 1.7.0\n' + version = err.split(" ")[-1:][0].strip() + ver = tuple(map(int, re.split('[\D]', version))) + except: + try: + # sphinx-build returns its version info in stdout + version = ctx.cmd_and_log(ctx.env.BIN_SPHINX_BUILD + + ['--version']).split(" ")[-1:][0].strip() + try: + ver = tuple(map(int, re.split('[\D]', version))) + except: + ctx.fatal("Sphinx version cannot be checked") + except: + ctx.fatal("Sphinx version cannot be checked: %s" % version) if ver < minver: ctx.fatal("Sphinx version is too old: %s" % ".".join(map(str, ver))) return ver -- cgit v1.2.3