From e99e2b18e063567e5df15d799ac6fb24ea4bf6c5 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 19 Aug 2013 17:43:32 -0400 Subject: [PATCH] Call sphinx-build from withing Python instead of a subprocess --- hscommon/sphinxgen.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hscommon/sphinxgen.py b/hscommon/sphinxgen.py index 7ca48365..35c86c4f 100644 --- a/hscommon/sphinxgen.py +++ b/hscommon/sphinxgen.py @@ -9,7 +9,9 @@ import os.path as op import re -from .build import print_and_do, read_changelog_file, filereplace +from pkg_resources import load_entry_point + +from .build import read_changelog_file, filereplace CHANGELOG_FORMAT = """ {version} ({date}) @@ -58,5 +60,10 @@ def gen(basepath, destpath, changelogpath, tixurl, confrepl=None, confpath=None, filereplace(changelogtmpl, changelog_out, changelog='\n'.join(rendered_logs)) conf_out = op.join(basepath, 'conf.py') filereplace(confpath, conf_out, **confrepl) - cmd = 'sphinx-build "{}" "{}"'.format(basepath, destpath) - print_and_do(cmd) + # We used to call sphinx-build with print_and_do(), but the problem was that the virtualenv + # of the calling python wasn't correctly considered and caused problems with documentation + # relying on autodoc (which tries to import the module to auto-document, but fail because of + # missing dependencies which are in the virtualenv). Here, we do exactly what is done when + # calling the command from bash. + cmd = load_entry_point('Sphinx', 'console_scripts', 'sphinx-build') + cmd(['sphinx-build', basepath, destpath])