diff options
author | Daniel Wyatt <[email protected]> | 2018-06-04 22:55:24 -0400 |
---|---|---|
committer | Daniel Wyatt <[email protected]> | 2018-06-04 23:09:27 -0400 |
commit | b4cb7786a2d2d9f20686cb270921569751bd1980 (patch) | |
tree | f6366aee234f53a6fd35280ae6445dd1ebe22185 /src | |
parent | da70cf93ee0cc5971fc0cb2fba1ef58d105f9e98 (diff) |
Conditionally use concurrency with sphinx-build.
Diffstat (limited to 'src')
-rwxr-xr-x | src/scripts/build_docs.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/scripts/build_docs.py b/src/scripts/build_docs.py index 3cc59c07c..9b0e37960 100755 --- a/src/scripts/build_docs.py +++ b/src/scripts/build_docs.py @@ -120,6 +120,22 @@ def parse_options(args): return options +def sphinx_supports_concurrency(): + import re + from distutils.version import StrictVersion + + proc = subprocess.Popen(['sphinx-build', '--version'], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + output, _ = proc.communicate() + if isinstance(output, bytes): + output = output.decode('ascii') + # Sphinx v1.1.3 + # sphinx-build 1.7.4 + match = re.match(r'^(?:[a-zA-Z_-]+) v?(([0-9]+)\.([0-9]+))', output) + # default to using concurrency when uncertain + version = StrictVersion(match.group(1)) if match else StrictVersion('1.2') + return version >= StrictVersion('1.2') def main(args=None): # pylint: disable=too-many-branches,too-many-locals @@ -160,8 +176,9 @@ def main(args=None): if with_sphinx: sphinx_build = ['sphinx-build', - '-c', cfg['sphinx_config_dir'], - '-j', str(get_concurrency())] + '-c', cfg['sphinx_config_dir']] + if sphinx_supports_concurrency(): + sphinx_build += ['-j', str(get_concurrency())] cmds.append(sphinx_build + ['-b', 'html', manual_src, manual_output]) |