Call sphinx-build from withing Python instead of a subprocess

This commit is contained in:
Virgil Dupras 2013-08-19 17:43:32 -04:00
parent ae1283f2e1
commit e99e2b18e0
1 changed files with 10 additions and 3 deletions

View File

@ -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])