Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 09 Feb 2022 09:39:36
Message-Id: 1644396227.c14accfbbdcef56f2cded18b94e38de8f02ed77c.mgorny@gentoo
1 commit: c14accfbbdcef56f2cded18b94e38de8f02ed77c
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Feb 4 17:15:21 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Feb 9 08:43:47 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c14accfb
7
8 python-utils-r1.eclass: Fix sphinx_build for non-autodoc case
9
10 Fix the regression in calling sphinx-build for the non-autodoc case
11 that causes the build to fail if dev-python/sphinx isn't built
12 for the newest Python interpreter available. To account for this,
13 we need to call sphinx-build as an executable (i.e. via python-exec).
14
15 Ideally, build_sphinx would be aware of which case it is used for,
16 and use appropriate invocation. Unfortunately, we cannot do that
17 without breaking backwards compatibility. However, we can simply check
18 if Sphinx is available via ${EPYTHON}, and fall back to calling
19 python-exec directly. This is effectively equivalent to choosing
20 the specific invocation directly, as python-exec would have respected
21 the implementation specified by EPYTHON anyway if sphinx-build
22 executable was available for it.
23
24 Fixes: f6a17acb8b7c (...: Run sphinx-build via EPYTHON)
25 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
26
27 eclass/python-utils-r1.eclass | 22 ++++++++++++++++++----
28 1 file changed, 18 insertions(+), 4 deletions(-)
29
30 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
31 index 3d938f5ee74f..255e30277f5e 100644
32 --- a/eclass/python-utils-r1.eclass
33 +++ b/eclass/python-utils-r1.eclass
34 @@ -1231,10 +1231,24 @@ build_sphinx() {
35
36 sed -i -e 's:^intersphinx_mapping:disabled_&:' \
37 "${dir}"/conf.py || die
38 - # not all packages include the Makefile in pypi tarball
39 - "${EPYTHON}" -m sphinx.cmd.build \
40 - -b html -d "${dir}"/_build/doctrees "${dir}" \
41 - "${dir}"/_build/html || die
42 + # 1. not all packages include the Makefile in pypi tarball,
43 + # so we call sphinx-build directly
44 + # 2. if autodoc is used, we need to call sphinx via EPYTHON,
45 + # to ensure that PEP 517 venv is respected
46 + # 3. if autodoc is not used, then sphinx might not be installed
47 + # for the current impl, so we need a fallback to sphinx-build
48 + local command=( "${EPYTHON}" -m sphinx.cmd.build )
49 + if ! "${EPYTHON}" -c "import sphinx.cmd.build" 2>/dev/null; then
50 + command=( sphinx-build )
51 + fi
52 + command+=(
53 + -b html
54 + -d "${dir}"/_build/doctrees
55 + "${dir}"
56 + "${dir}"/_build/html
57 + )
58 + echo "${command[@]}" >&2
59 + "${command[@]}" || die
60
61 HTML_DOCS+=( "${dir}/_build/html/." )
62 }