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