python-utils-r1.eclass: Fix sphinx_build for non-autodoc case

Fix the regression in calling sphinx-build for the non-autodoc case
that causes the build to fail if dev-python/sphinx isn't built
for the newest Python interpreter available.  To account for this,
we need to call sphinx-build as an executable (i.e. via python-exec).

Ideally, build_sphinx would be aware of which case it is used for,
and use appropriate invocation.  Unfortunately, we cannot do that
without breaking backwards compatibility.  However, we can simply check
if Sphinx is available via ${EPYTHON}, and fall back to calling
python-exec directly.  This is effectively equivalent to choosing
the specific invocation directly, as python-exec would have respected
the implementation specified by EPYTHON anyway if sphinx-build
executable was available for it.

Fixes: f6a17acb8b (...: Run sphinx-build via EPYTHON)
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2022-02-09 09:43:47 +01:00
parent 1788cb332f
commit c14accfbbd
+18 -4
View File
@@ -1231,10 +1231,24 @@ build_sphinx() {
sed -i -e 's:^intersphinx_mapping:disabled_&:' \
"${dir}"/conf.py || die
# not all packages include the Makefile in pypi tarball
"${EPYTHON}" -m sphinx.cmd.build \
-b html -d "${dir}"/_build/doctrees "${dir}" \
"${dir}"/_build/html || die
# 1. not all packages include the Makefile in pypi tarball,
# so we call sphinx-build directly
# 2. if autodoc is used, we need to call sphinx via EPYTHON,
# to ensure that PEP 517 venv is respected
# 3. if autodoc is not used, then sphinx might not be installed
# for the current impl, so we need a fallback to sphinx-build
local command=( "${EPYTHON}" -m sphinx.cmd.build )
if ! "${EPYTHON}" -c "import sphinx.cmd.build" 2>/dev/null; then
command=( sphinx-build )
fi
command+=(
-b html
-d "${dir}"/_build/doctrees
"${dir}"
"${dir}"/_build/html
)
echo "${command[@]}" >&2
"${command[@]}" || die
HTML_DOCS+=( "${dir}/_build/html/." )
}