summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-02-04 18:15:21 +0100
committerMichał Górny <mgorny@gentoo.org>2022-02-09 09:43:47 +0100
commitc14accfbbdcef56f2cded18b94e38de8f02ed77c (patch)
tree6173303c70a4580ce71f38b184210c8b613a7917 /eclass/python-utils-r1.eclass
parentdistutils-r1.eclass: Fix has_version for distutils_enable_sphinx (diff)
downloadgentoo-c14accfbbdcef56f2cded18b94e38de8f02ed77c.tar.gz
gentoo-c14accfbbdcef56f2cded18b94e38de8f02ed77c.tar.bz2
gentoo-c14accfbbdcef56f2cded18b94e38de8f02ed77c.zip
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: f6a17acb8b7c (...: Run sphinx-build via EPYTHON) Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r--eclass/python-utils-r1.eclass22
1 files changed, 18 insertions, 4 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 3d938f5ee74f..255e30277f5e 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -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/." )
}