docs: scripts: sphinx-pre-install: Fix building docs with pyyaml package

Message ID 20240207111236.7242-1-thorsten.blum@toblux.com
State New
Headers
Series docs: scripts: sphinx-pre-install: Fix building docs with pyyaml package |

Commit Message

Thorsten Blum Feb. 7, 2024, 11:12 a.m. UTC
  The Python module pyyaml is required to build the docs, but it is only
listed in Documentation/sphinx/requirements.txt and is therefore missing
when Sphinx is installed as a package and not via pip/pypi.

Add pyyaml as an optional package for Debian- and Red Hat-based distros to
fix building the docs if you prefer to install Sphinx as a package.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 scripts/sphinx-pre-install | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Vegard Nossum Feb. 8, 2024, 10:21 a.m. UTC | #1
On 07/02/2024 12:12, Thorsten Blum wrote:
> The Python module pyyaml is required to build the docs, but it is only
> listed in Documentation/sphinx/requirements.txt and is therefore missing
> when Sphinx is installed as a package and not via pip/pypi.
> 
> Add pyyaml as an optional package for Debian- and Red Hat-based distros to
> fix building the docs if you prefer to install Sphinx as a package.

Thanks for fixing this!

> @@ -955,6 +957,7 @@ sub check_needs()
>   	check_program("gcc", 0);
>   	check_program("dot", 1);
>   	check_program("convert", 1);
> +	check_python_module("pyyaml", 1);

Shouldn't this be just "yaml" instead of "pyyaml"? check_python_module()
is going to "import" that argument and the Python module itself is just
called "yaml".

Hm, but then it's going to add "yaml" to %missing, which keys on
packages, not modules... Maybe add an optional argument to
check_python_module() so that it knows both the Python module name and
the package name?

As usual, I could be wrong...


Vegard
  

Patch

diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install
index 25aefbb35377..7905beab3359 100755
--- a/scripts/sphinx-pre-install
+++ b/scripts/sphinx-pre-install
@@ -361,6 +361,7 @@  sub give_debian_hints()
 {
 	my %map = (
 		"python-sphinx"		=> "python3-sphinx",
+		"pyyaml"		=> "python3-yaml",
 		"ensurepip"		=> "python3-venv",
 		"virtualenv"		=> "virtualenv",
 		"dot"			=> "graphviz",
@@ -395,6 +396,7 @@  sub give_redhat_hints()
 {
 	my %map = (
 		"python-sphinx"		=> "python3-sphinx",
+		"pyyaml"		=> "python3-pyyaml",
 		"virtualenv"		=> "python3-virtualenv",
 		"dot"			=> "graphviz",
 		"convert"		=> "ImageMagick",
@@ -955,6 +957,7 @@  sub check_needs()
 	check_program("gcc", 0);
 	check_program("dot", 1);
 	check_program("convert", 1);
+	check_python_module("pyyaml", 1);
 
 	# Extra PDF files - should use 2 for is_optional
 	check_program("xelatex", 2) if ($pdf);