From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6949E2F8BEC; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=f4n3b5FiwunC8J97pZdW36rCffh7BfXdqm/poz56NQaNJfPD8W4OguIBsSH8zu9Ypn9XgR5zJ8aInf+LSduyVUEZFVoWQcCdgtXYeuHTz8TBx+MDf2WGv/lppNPcnWoSOGZAjzbeU+U0xbjwOZUT/6HBQ+Y5yOHxBAssY+flvJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=6213I1YGIhaAMSl82yuZqy7K1JDcqwNqRPbmxLRGh8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ma/2+LBCpc+bGm/bIIHT5xi+oyzzGh/PGutFWMfY6yHDFNpkhsMqFQLXtRGiNOG5rRUIxTuPdN5FyXzQfjwQIG4RfdXbufWFPoVUgauFDL8ubi8gqcLCtB9reKyy0QzivPuwoJhGIOT1HjAueG6r3Ud8sKVMwOwLHQwwLDZ8iwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KTbzYx5u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KTbzYx5u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC7CDC4CEFA; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=6213I1YGIhaAMSl82yuZqy7K1JDcqwNqRPbmxLRGh8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTbzYx5usqNc8tDJUk72dsA35+q+q8EvkiAJSbLo0ymHr4hCJ4m4ePp2RnNn6e3rf /hn7kyxma85yroK5mNSQLaB78QTOaS8Nvon+7FmknV6Gags5l131qZxBiSjZh0DauL 2kbFLmtQu4WDKwr/ZeMyFB12UQB+Mwiycap+Crcpcr3BD/tB4pQFKJJmSd6cB8TZD0 /SjnOM3DL2ZQNUbeF7So3ZT4cE+AvVuYcq0SVzbHP+o6PA64tWGmHQhY36CiL7LUQW qtc+7wPbH5wJSgM3whxX2BdyXbm1wB1HB7NDitDcNTTqz7cSAT9iQ8w+2zEYswT/3B bRy+1Hq2OhicA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVG-0KdN; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 01/39] scripts: sphinx-pre-install: fix version check for Fedora Date: Tue, 12 Aug 2025 17:52:18 +0200 Message-ID: <9d1e5c9906534e2bae586f891770066346463146.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The script is now picking the wrong version. Fix it. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install index 3f8d6925e896..07234d482fa8 100755 --- a/scripts/sphinx-pre-install +++ b/scripts/sphinx-pre-install @@ -413,7 +413,7 @@ sub give_redhat_hints() my $old =3D 0; my $rel; my $noto_sans_redhat =3D "google-noto-sans-cjk-ttc-fonts"; - $rel =3D $1 if ($system_release =3D~ /(release|Linux)\s+(\d+)/); + $rel =3D $2 if ($system_release =3D~ /(release|Linux)\s+(\d+)/); =20 if (!($system_release =3D~ /Fedora/)) { $map{"virtualenv"} =3D "python-virtualenv"; --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 470BE2F28E2; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=HR+ZX7ERCVFHhLHYCnnlIxZmjNYKQ04/Zfk556QxwbMNvYCdos45ylL9BoaCv8DqUzlmzoUPKWaipaxEKwDBu0XLjJxWE0K/3SvECU7ItubfB0xAdC0tjCg1k+65DHjIfepRE+xmd+UtPevNoGl8wo+ox6PqWWOwZp5P+yd1a9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=8zP8NZvDvUvs74ttgmIZZECJykztS2ZwmnhgJaultkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hCWrHgwcsh5r0wl7sQwPS4kmj5URfpcR1UWb8WHH93aXhAsY4sKCm4g9F6Pon8z3wiHrgn92bqV6+ybDp1eoLqHPomCg5g7nDUMjII+RoY3uSwtlbE6ycsz1gGAUw5adcd5sy6ebEFYB3h3YON9XltyFWBuOgx4D+EDFVV61rRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rpmT1wJP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rpmT1wJP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B97C4CEFB; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=8zP8NZvDvUvs74ttgmIZZECJykztS2ZwmnhgJaultkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rpmT1wJPOBB0McfHSic7rm7vkIGC7mGedxK4InyrjTYusUS5pYW2aDip4GdakkvBE UFOYNauGqhvMkXHAh0ECEwJ8NHPgD1bDguGu9/BV4rL4tJ3QOyv8cquT+LUSW6xABi fLEQqgj8yFZOPcaq1ulj42+9iqF+W5SdBXzr0be+rhZJvphyIy2QdLpvgWfZLZfwlq 9mxWWFPu47SiATrGcwnKMkVnqxWYGeMvAhBweDdNhUBrbPc0u2gaZrKSSUxDSlQL3+ a+3eHtDiKvhVCdPSzzPREVhEQWWWnPYdpFkQWAWka86wq7hO1jSRbnS9PIcdimN68f 70PBkNf+excTQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVK-0SXG; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 02/39] scripts: sphinx-pre-install: rename it to scripts/sphinx-pre-install.pl Date: Tue, 12 Aug 2025 17:52:19 +0200 Message-ID: <08d9a32a5aaf3784fef016594efe505d7c5a2697.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" That helps us to later replace the scripts. Signed-off-by: Mauro Carvalho Chehab --- Documentation/Makefile | 14 +++++++------- .../{sphinx-pre-install =3D> sphinx-pre-install.pl} | 0 2 files changed, 7 insertions(+), 7 deletions(-) rename scripts/{sphinx-pre-install =3D> sphinx-pre-install.pl} (100%) diff --git a/Documentation/Makefile b/Documentation/Makefile index b98477df5ddf..c486fe3cc5e1 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -46,7 +46,7 @@ ifeq ($(HAVE_SPHINX),0) .DEFAULT: $(warning The '$(SPHINXBUILD)' command was not found. Make sure you have = Sphinx installed and in PATH, or set the SPHINXBUILD make variable to point= to the full path of the '$(SPHINXBUILD)' executable.) @echo - @$(srctree)/scripts/sphinx-pre-install + @$(srctree)/scripts/sphinx-pre-install.pl @echo " SKIP Sphinx $@ target." =20 else # HAVE_SPHINX @@ -121,7 +121,7 @@ $(YNL_RST_DIR)/%.rst: $(YNL_YAML_DIR)/%.yaml $(YNL_TOOL) htmldocs texinfodocs latexdocs epubdocs xmldocs: $(YNL_INDEX) =20 htmldocs: - @$(srctree)/scripts/sphinx-pre-install --version-check + @$(srctree)/scripts/sphinx-pre-install.pl --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) =20 # If Rust support is available and .config exists, add rustdoc generated c= ontents. @@ -135,7 +135,7 @@ endif endif =20 texinfodocs: - @$(srctree)/scripts/sphinx-pre-install --version-check + @$(srctree)/scripts/sphinx-pre-install.pl --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texin= fo,$(var))) =20 # Note: the 'info' Make target is generated by sphinx itself when @@ -147,7 +147,7 @@ linkcheckdocs: @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(v= ar))) =20 latexdocs: - @$(srctree)/scripts/sphinx-pre-install --version-check + @$(srctree)/scripts/sphinx-pre-install.pl --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$= (var))) =20 ifeq ($(HAVE_PDFLATEX),0) @@ -160,7 +160,7 @@ else # HAVE_PDFLATEX =20 pdfdocs: DENY_VF =3D XDG_CONFIG_HOME=3D$(FONTS_CONF_DENY_VF) pdfdocs: latexdocs - @$(srctree)/scripts/sphinx-pre-install --version-check + @$(srctree)/scripts/sphinx-pre-install.pl --version-check $(foreach var,$(SPHINXDIRS), \ $(MAKE) PDFLATEX=3D"$(PDFLATEX)" LATEXOPTS=3D"$(LATEXOPTS)" $(DENY_VF)= -C $(BUILDDIR)/$(var)/latex || sh $(srctree)/scripts/check-variable-fonts.= sh || exit; \ mkdir -p $(BUILDDIR)/$(var)/pdf; \ @@ -170,11 +170,11 @@ pdfdocs: latexdocs endif # HAVE_PDFLATEX =20 epubdocs: - @$(srctree)/scripts/sphinx-pre-install --version-check + @$(srctree)/scripts/sphinx-pre-install.pl --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(v= ar))) =20 xmldocs: - @$(srctree)/scripts/sphinx-pre-install --version-check + @$(srctree)/scripts/sphinx-pre-install.pl --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var= ))) =20 endif # HAVE_SPHINX diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install.pl similarity index 100% rename from scripts/sphinx-pre-install rename to scripts/sphinx-pre-install.pl --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF2C02F83C7; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=nopr2Q0rMUFsQKG4SkspoVWj5088sbzD/9B+Fn+Any0FrXltZFOB6K7xlx4XkG7k6/bAbLjbky8yjHwu/6uwZK5Sn66xZjGC/fOtqI6fYQC48GUDnEiu5vhSsWmdSZ//slsjr1fIPh/LLu7L1xourB3XHbO5PcGa/2S7hX7y8CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=GP+MW2s/zTSB/+UK2ocQ681sCcygyqTVY/AjkcHfkCk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iac63gXeq9kVr3Z2ZVqjmvPfYZnzj+H2Ty4SM5jwc726/DqQJsmhQ2mlCkmlO/Pg69GTQpaw9eboU0Ivu9CyUP8MEoRSIyRKrpb8CDilfOILHS5sT8CYf2Jrx6U2hIpPHcvfIbdKjJHomnq7c+cRgwdtubfRgFmCitNqE048Ens= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X4crMkRJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X4crMkRJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3632C116D0; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=GP+MW2s/zTSB/+UK2ocQ681sCcygyqTVY/AjkcHfkCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4crMkRJQmjS8YGltWfusYezy5HShNP0zyvgiXpDUNNQXQ1OFsM93gKZoPJLt9WED StZ37+TwLcJ+xIbTUQya5djojblPv/u8sLqEXlJaWBeRY1sQkbyyDZoWx6SGp63eB3 bz4CkiMArX2W28QIxOrTYqiUnlh9pkAhgF2aHS5AFkdexMi/KGE4nzJY3B+OgGns8i r/BoYlWo0FskU/a06yBf3m8m9Y/eot/icQh2rF1xKr/OMeg3flM3adsEZHS7GfOotf ky+J482leXG26YOBgfnahua8XaS79wsWmW4Qak/8lKbdnk6ZUnSdXeoNjBW2QMdSoJ +A46CyPAc9xEA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVO-0bWV; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 03/39] scripts: sphinx-pre-install: Convert script to Python Date: Tue, 12 Aug 2025 17:52:20 +0200 Message-ID: <8d236079545aff796900bde4cdaaf79411d04074.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Port scripts/sphinx-pre-install to Python. That allows a better maintainance of the file. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 1102 +++++++++++++++++++++++++++++++++ 1 file changed, 1102 insertions(+) create mode 100755 scripts/sphinx-pre-install.py diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py new file mode 100755 index 000000000000..dcee2181b72f --- /dev/null +++ b/scripts/sphinx-pre-install.py @@ -0,0 +1,1102 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2017-2025 Mauro Carvalho Chehab +# +# pylint: disable=3DC0103,C0114,C0115,C0116,C0301 +# pylint: disable=3DR0902,R0904,R0912,R0915,R1705,R1710,E1121 + + +import argparse +import os +import re +import subprocess +import sys +from glob import glob + + +def parse_version(version): + """Convert a major.minor.patch version into a tuple""" +# + return tuple(int(x) for x in version.split(".")) + + +def ver_str(version): + """Returns a version tuple as major.minor.patch""" + + return ".".join([str(x) for x in version]) + + +RECOMMENDED_VERSION =3D parse_version("3.4.3") + + +class SphinxDependencyChecker: + # List of required texlive packages on Fedora and OpenSuse + texlive =3D { + "amsfonts.sty": "texlive-amsfonts", + "amsmath.sty": "texlive-amsmath", + "amssymb.sty": "texlive-amsfonts", + "amsthm.sty": "texlive-amscls", + "anyfontsize.sty": "texlive-anyfontsize", + "atbegshi.sty": "texlive-oberdiek", + "bm.sty": "texlive-tools", + "capt-of.sty": "texlive-capt-of", + "cmap.sty": "texlive-cmap", + "ctexhook.sty": "texlive-ctex", + "ecrm1000.tfm": "texlive-ec", + "eqparbox.sty": "texlive-eqparbox", + "eu1enc.def": "texlive-euenc", + "fancybox.sty": "texlive-fancybox", + "fancyvrb.sty": "texlive-fancyvrb", + "float.sty": "texlive-float", + "fncychap.sty": "texlive-fncychap", + "footnote.sty": "texlive-mdwtools", + "framed.sty": "texlive-framed", + "luatex85.sty": "texlive-luatex85", + "multirow.sty": "texlive-multirow", + "needspace.sty": "texlive-needspace", + "palatino.sty": "texlive-psnfss", + "parskip.sty": "texlive-parskip", + "polyglossia.sty": "texlive-polyglossia", + "tabulary.sty": "texlive-tabulary", + "threeparttable.sty": "texlive-threeparttable", + "titlesec.sty": "texlive-titlesec", + "ucs.sty": "texlive-ucs", + "upquote.sty": "texlive-upquote", + "wrapfig.sty": "texlive-wrapfig", + } + + def __init__(self, args): + self.pdf =3D args.pdf + self.virtualenv =3D args.virtualenv + self.version_check =3D args.version_check + + self.missing =3D {} + + self.need =3D 0 + self.optional =3D 0 + self.need_symlink =3D 0 + self.need_sphinx =3D 0 + self.need_pip =3D 0 + self.need_virtualenv =3D 0 + self.rec_sphinx_upgrade =3D 0 + self.verbose_warn_install =3D 1 + + self.system_release =3D "" + self.install =3D "" + self.virtenv_dir =3D "" + self.python_cmd =3D "" + self.activate_cmd =3D "" + + self.min_version =3D (0, 0, 0) + self.cur_version =3D (0, 0, 0) + self.latest_avail_ver =3D (0, 0, 0) + self.venv_ver =3D (0, 0, 0) + + prefix =3D os.environ.get("srctree", ".") + "/" + + self.conf =3D prefix + "Documentation/conf.py" + self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" + self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] + + # + # Ancillary methods that don't depend on self + # + + @staticmethod + def which(prog): + for path in os.environ.get("PATH", "").split(":"): + full_path =3D os.path.join(path, prog) + if os.access(full_path, os.X_OK): + return full_path + + return None + + @staticmethod + def find_python_no_venv(): + # FIXME: does it makes sense now that this script is in Python? + + result =3D subprocess.run(["pwd"], capture_output=3DTrue, text=3DT= rue) + cur_dir =3D result.stdout.strip() + + python_names =3D ["python3", "python"] + + for d in os.environ.get("PATH", "").split(":"): + if f"{cur_dir}/sphinx" in d: + continue + + for p in python_names: + if os.access(os.path.join(d, p), os.X_OK): + return os.path.join(d, p) + + # Python not found at the PATH + return python_names[-1] + + @staticmethod + def run(*args, **kwargs): + """Excecute a command, hiding its output by default""" + + if not kwargs.get('capture_output', False): + if 'stdout' not in kwargs: + kwargs['stdout'] =3D subprocess.DEVNULL + if 'stderr' not in kwargs: + kwargs['stderr'] =3D subprocess.DEVNULL + + return subprocess.run(*args, **kwargs) + + # + # Methods to check if a feature exists + # + + # Note: is_optional has 3 states: + # - 0: mandatory + # - 1: optional, but nice to have + # - 2: LaTeX optional - pdf builds without it, but may have visual i= mpact + + def check_missing(self, progs): + for prog, is_optional in sorted(self.missing.items()): + # At least on some LTS distros like CentOS 7, texlive doesn't + # provide all packages we need. When such distros are + # detected, we have to disable PDF output. + # + # So, we need to ignore the packages that distros would + # need for LaTeX to work + if is_optional =3D=3D 2 and not self.pdf: + self.optional -=3D 1 + continue + + if self.verbose_warn_install: + if is_optional: + print(f'Warning: better to also install "{prog}".') + else: + print(f'ERROR: please install "{prog}", otherwise, bui= ld won\'t work.') + + self.install +=3D " " + progs.get(prog, prog) + + self.install =3D self.install.lstrip() + + def add_package(self, package, is_optional): + self.missing[package] =3D is_optional + if is_optional: + self.optional +=3D 1 + else: + self.need +=3D 1 + + def check_missing_file(self, files, package, is_optional): + for f in files: + if os.path.exists(f): + return + self.add_package(package, is_optional) + + def check_program(self, prog, is_optional): + found =3D self.which(prog) + if found: + return found + + self.add_package(prog, is_optional) + + return None + + def check_perl_module(self, prog, is_optional): + # While testing with lxc download template, one of the + # distros (Oracle) didn't have perl - nor even an option to install + # before installing oraclelinux-release-el9 package. + # + # Check it before running an error. If perl is not there, + # add it as a mandatory package, as some parts of the doc builder + # needs it. + if not self.which("perl"): + self.add_package("perl", 0) + self.add_package(prog, is_optional) + return + + try: + self.run(["perl", f"-M{prog}", "-e", "1"], check=3DTrue) + except subprocess.CalledProcessError: + self.add_package(prog, is_optional) + + def check_python_module(self, module, is_optional): + # FIXME: is it needed at the Python version? Maybe due to venv? + if not self.python_cmd: + return + + try: + self.run([self.python_cmd, "-c", f"import {module}"], check=3D= True) + except subprocess.CalledProcessError: + self.add_package(module, is_optional) + + def check_rpm_missing(self, pkgs, is_optional): + for prog in pkgs: + try: + self.run(["rpm", "-q", prog], check=3DTrue) + except subprocess.CalledProcessError: + self.add_package(prog, is_optional) + + def check_pacman_missing(self, pkgs, is_optional): + for prog in pkgs: + try: + self.run(["pacman", "-Q", prog], check=3DTrue) + except subprocess.CalledProcessError: + self.add_package(prog, is_optional) + + def check_missing_tex(self, is_optional): + kpsewhich =3D self.which("kpsewhich") + for prog, package in self.texlive.items(): + + # If kpsewhich is not there, just add it to deps + if not kpsewhich: + self.add_package(package, is_optional) + continue + + # Check if the package is needed + try: + result =3D self.run( + [kpsewhich, prog], stdout=3Dsubprocess.PIPE, text=3DTr= ue, check=3DTrue + ) + + # Didn't find. Add it + if not result.stdout.strip(): + self.add_package(package, is_optional) + + except subprocess.CalledProcessError: + # kpsewhich returned an error. Add it, just in case + self.add_package(package, is_optional) + + def get_sphinx_fname(self): + if "SPHINXBUILD" in os.environ: + return os.environ["SPHINXBUILD"] + + fname =3D "sphinx-build" + if self.which(fname): + return fname + + fname =3D "sphinx-build-3" + if self.which(fname): + self.need_symlink =3D 1 + return fname + + return "" + + def get_sphinx_version(self, cmd): + try: + result =3D self.run([cmd, "--version"], + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, + text=3DTrue, check=3DTrue) + except (subprocess.CalledProcessError, FileNotFoundError): + return None + + for line in result.stdout.split("\n"): + match =3D re.match(r"^sphinx-build\s+([\d\.]+)(?:\+(?:/[\da-f]= +)|b\d+)?\s*$", line) + if match: + return parse_version(match.group(1)) + + match =3D re.match(r"^Sphinx.*\s+([\d\.]+)\s*$", line) + if match: + return parse_version(match.group(1)) + + def check_sphinx(self): + try: + with open(self.conf, "r", encoding=3D"utf-8") as f: + for line in f: + match =3D re.match(r"^\s*needs_sphinx\s*=3D\s*[\'\"]([= \d\.]+)[\'\"]", line) + if match: + self.min_version =3D parse_version(match.group(1)) + break + except IOError: + sys.exit(f"Can't open {self.conf}") + + if not self.min_version: + sys.exit(f"Can't get needs_sphinx version from {self.conf}") + + self.virtenv_dir =3D self.virtenv_prefix[0] + "latest" + + sphinx =3D self.get_sphinx_fname() + if not sphinx: + self.need_sphinx =3D 1 + return + + self.cur_version =3D self.get_sphinx_version(sphinx) + if not self.cur_version: + sys.exit(f"{sphinx} didn't return its version") + + if self.cur_version < self.min_version: + curver =3D ver_str(self.cur_version) + minver =3D ver_str(self.min_version) + + print(f"ERROR: Sphinx version is {curver}. It should be >=3D {= minver}") + self.need_sphinx =3D 1 + return + + # On version check mode, just assume Sphinx has all mandatory deps + if self.version_check and self.cur_version >=3D RECOMMENDED_VERSIO= N: + sys.exit(0) + + def catcheck(self, filename): + if os.path.exists(filename): + with open(filename, "r", encoding=3D"utf-8") as f: + return f.read().strip() + return "" + + # + # Distro-specific hints methods + # + + def give_debian_hints(self): + progs =3D { + "Pod::Usage": "perl-modules", + "convert": "imagemagick", + "dot": "graphviz", + "ensurepip": "python3-venv", + "python-sphinx": "python3-sphinx", + "rsvg-convert": "librsvg2-bin", + "virtualenv": "virtualenv", + "xelatex": "texlive-xetex", + "yaml": "python3-yaml", + } + + if self.pdf: + pdf_pkgs =3D { + "texlive-lang-chinese": [ + "/usr/share/texlive/texmf-dist/tex/latex/ctex/ctexhook= .sty", + ], + "fonts-dejavu": [ + "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", + ], + "fonts-noto-cjk": [ + "/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", + "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.tt= c", + "/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.t= tc", + ], + } + + for package, files in pdf_pkgs.items(): + self.check_missing_file(files, package, 2) + + self.check_program("dvipng", 2) + + self.check_missing(progs) + + if not self.need and not self.optional: + return + + if self.verbose_warn_install: + print("You should run:") + print(f"\n\tsudo apt-get install {self.install}") + + def give_redhat_hints(self): + progs =3D { + "Pod::Usage": "perl-Pod-Usage", + "convert": "ImageMagick", + "dot": "graphviz", + "python-sphinx": "python3-sphinx", + "rsvg-convert": "librsvg2-tools", + "virtualenv": "python3-virtualenv", + "xelatex": "texlive-xetex-bin", + "yaml": "python3-pyyaml", + } + + fedora26_opt_pkgs =3D [ + "graphviz-gd", # Fedora 26: needed for PDF support + ] + + fedora_tex_pkgs =3D [ + "dejavu-sans-fonts", + "dejavu-sans-mono-fonts", + "dejavu-serif-fonts", + "texlive-collection-fontsrecommended", + "texlive-collection-latex", + "texlive-xecjk", + ] + + old =3D 0 + rel =3D None + pkg_manager =3D "dnf" + + match =3D re.search(r"(release|Linux)\s+(\d+)", self.system_releas= e) + if match: + rel =3D int(match.group(2)) + + if not rel: + print("Couldn't identify release number") + old =3D 1 + self.pdf =3D False + elif re.search("Fedora", self.system_release): + # Fedora 38 and upper use this CJK font + + noto_sans_redhat =3D "google-noto-sans-cjk-fonts" + else: + # Almalinux, CentOS, RHEL, ... + + # at least up to version 9 (and Fedora < 38), that's the CJK f= ont + noto_sans_redhat =3D "google-noto-sans-cjk-ttc-fonts" + + progs["virtualenv"] =3D "python-virtualenv" + + if rel and rel < 8: + old =3D 1 + self.pdf =3D False + + # RHEL 7 is in ELS, currently up to Jun, 2026 + + print("Note: texlive packages on RHEL/CENTOS <=3D 7 are in= complete. Can't support PDF output") + print("If you want to build PDF, please read:") + print("\thttps://www.systutorials.com/241660/how-to-instal= l-tex-live-on-centos-7-linux/") + + if self.pdf: + pdf_pkgs =3D [ + "/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", + "/usr/share/fonts/google-noto-sans-cjk-fonts/NotoSansCJK-R= egular.ttc", + ] + + self.check_missing_file(pdf_pkgs, noto_sans_redhat, 2) + + if not old: + self.check_rpm_missing(fedora26_opt_pkgs, 2) + self.check_rpm_missing(fedora_tex_pkgs, 2) + + self.check_missing_tex(2) + + self.check_missing(progs) + + if not self.need and not self.optional: + return + + if self.verbose_warn_install: + print("You should run:") + + if old: + # dnf is there since Fedora 18+ and RHEL 8 + pkg_manager =3D "yum" + + print(f"\n\tsudo {pkg_manager} install -y {self.install}") + + def give_opensuse_hints(self): + progs =3D { + "Pod::Usage": "perl-Pod-Usage", + "convert": "ImageMagick", + "dot": "graphviz", + "python-sphinx": "python3-sphinx", + "virtualenv": "python3-virtualenv", + "xelatex": "texlive-xetex-bin", + "yaml": "python3-pyyaml", + } + + # On Tumbleweed, this package is also named rsvg-convert + if not re.search(r"Tumbleweed", self.system_release): + progs["rsvg-convert"] =3D "rsvg-view" + + suse_tex_pkgs =3D [ + "texlive-babel-english", + "texlive-caption", + "texlive-colortbl", + "texlive-courier", + "texlive-dvips", + "texlive-helvetic", + "texlive-makeindex", + "texlive-metafont", + "texlive-metapost", + "texlive-palatino", + "texlive-preview", + "texlive-times", + "texlive-zapfchan", + "texlive-zapfding", + ] + + progs["latexmk"] =3D "texlive-latexmk-bin" + + # FIXME: add support for installing CJK fonts + # + # I tried hard, but was unable to find a way to install + # "Noto Sans CJK SC" on openSUSE + + if self.pdf: + self.check_rpm_missing(suse_tex_pkgs, 2) + if self.pdf: + self.check_missing_tex(2) + self.check_missing(progs) + + if not self.need and not self.optional: + return + + if self.verbose_warn_install: + print("You should run:") + print(f"\n\tsudo zypper install --no-recommends {self.install}") + + def give_mageia_hints(self): + progs =3D { + "Pod::Usage": "perl-Pod-Usage", + "convert": "ImageMagick", + "dot": "graphviz", + "python-sphinx": "python3-sphinx", + "rsvg-convert": "librsvg2", + "virtualenv": "python3-virtualenv", + "xelatex": "texlive", + "yaml": "python3-yaml", + } + + tex_pkgs =3D [ + "texlive-fontsextra", + ] + + if re.search(r"OpenMandriva", self.system_release): + packager_cmd =3D "dnf install" + noto_sans =3D "noto-sans-cjk-fonts" + tex_pkgs =3D ["texlive-collection-fontsextra"] + else: + packager_cmd =3D "urpmi" + noto_sans =3D "google-noto-sans-cjk-ttc-fonts" + + progs["latexmk"] =3D "texlive-collection-basic" + + if self.pdf: + pdf_pkgs =3D [ + "/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", + "/usr/share/fonts/TTF/NotoSans-Regular.ttf", + ] + + self.check_missing_file(pdf_pkgs, noto_sans, 2) + self.check_rpm_missing(tex_pkgs, 2) + + self.check_missing(progs) + + if not self.need and not self.optional: + return + if self.verbose_warn_install: + print("You should run:") + print(f"\n\tsudo {packager_cmd} {self.install}") + + def give_arch_linux_hints(self): + progs =3D { + "convert": "imagemagick", + "dot": "graphviz", + "latexmk": "texlive-core", + "rsvg-convert": "extra/librsvg", + "virtualenv": "python-virtualenv", + "xelatex": "texlive-xetex", + "yaml": "python-yaml", + } + + archlinux_tex_pkgs =3D [ + "texlive-core", + "texlive-latexextra", + "ttf-dejavu", + ] + + if self.pdf: + self.check_pacman_missing(archlinux_tex_pkgs, 2) + + self.check_missing_file( + ["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], + "noto-fonts-cjk", + 2, + ) + + self.check_missing(progs) + + if not self.need and not self.optional: + return + if self.verbose_warn_install: + print("You should run:") + print(f"\n\tsudo pacman -S {self.install}") + + def give_gentoo_hints(self): + progs =3D { + "convert": "media-gfx/imagemagick", + "dot": "media-gfx/graphviz", + "rsvg-convert": "gnome-base/librsvg", + "virtualenv": "dev-python/virtualenv", + "xelatex": "dev-texlive/texlive-xetex media-fonts/dejavu", + "yaml": "dev-python/pyyaml", + } + + if self.pdf: + pdf_pkgs =3D { + "media-fonts/dejavu": [ + "/usr/share/fonts/dejavu/DejaVuSans.ttf", + ], + "media-fonts/noto-cjk": [ + "/usr/share/fonts/noto-cjk/NotoSansCJKsc-Regular.otf", + "/usr/share/fonts/noto-cjk/NotoSerifCJK-Regular.ttc", + ], + } + for package, files in pdf_pkgs.items(): + self.check_missing_file(files, package, 2) + + self.check_missing(progs) + + if not self.need and not self.optional: + return + + if self.verbose_warn_install: + print("You should run:") + print("\n") + + imagemagick =3D "media-gfx/imagemagick svg png" + cairo =3D "media-gfx/graphviz cairo pdf" + portage_imagemagick =3D "/etc/portage/package.use/imagemagick" + portage_cairo =3D "/etc/portage/package.use/graphviz" + + result =3D self.run(["grep", "imagemagick", portage_imagemagick], + stdout=3Dsubprocess.PIPE, text=3DTrue) + if not result.stdout.strip(): + print(f"\tsudo su -c 'echo \"{imagemagick}\" > {portage_imagem= agick}'") + + result =3D self.run(["grep", "graphviz", portage_cairo], + stdout=3Dsubprocess.PIPE, text=3DTrue) + + if not result.stdout.strip(): + print(f"\tsudo su -c 'echo \"{cairo}\" > {portage_cairo}'") + + print(f"\tsudo emerge --ask {self.install}") + + # + # Dispatch the check to an os_specific hinter + # + + def check_distros(self): + # OS-specific hints logic + os_hints =3D { + re.compile("Red Hat Enterprise Linux"): self.give_redhat_hin= ts, + re.compile("Fedora"): self.give_redhat_hin= ts, + re.compile("AlmaLinux"): self.give_redhat_hin= ts, + re.compile("Amazon Linux"): self.give_redhat_hin= ts, + re.compile("CentOS"): self.give_redhat_hin= ts, + re.compile("openEuler"): self.give_redhat_hin= ts, + re.compile("Oracle Linux Server"): self.give_redhat_hin= ts, + re.compile("Rocky Linux"): self.give_redhat_hin= ts, + re.compile("Scientific Linux"): self.give_redhat_hin= ts, + re.compile("Springdale Open Enterprise"): self.give_redhat_hin= ts, + + re.compile("Ubuntu"): self.give_debian_hin= ts, + re.compile("Debian"): self.give_debian_hin= ts, + re.compile("Devuan"): self.give_debian_hin= ts, + re.compile("Kali"): self.give_debian_hin= ts, + re.compile("Mint"): self.give_debian_hin= ts, + + re.compile("openSUSE"): self.give_opensuse_h= ints, + + re.compile("Mageia"): self.give_mageia_hin= ts, + re.compile("OpenMandriva"): self.give_mageia_hin= ts, + + re.compile("Arch Linux"): self.give_arch_linux= _hints, + re.compile("Gentoo"): self.give_gentoo_hin= ts, + } + + # If the OS is detected, use per-OS hint logic + for regex, os_hint in os_hints.items(): + if regex.search(self.system_release): + os_hint() + + return + + # + # Fall-back to generic hint code for other distros + # That's far from ideal, specially for LaTeX dependencies. + # + progs =3D {"sphinx-build": "sphinx"} + if self.pdf: + self.check_missing_tex(2) + + self.check_missing(progs) + + print(f"I don't know distro {self.system_release}.") + print("So, I can't provide you a hint with the install procedure.") + print("There are likely missing dependencies.") + + # + # Common dependencies + # + def deactivate_help(self): + print("\n If you want to exit the virtualenv, you can use:") + print("\tdeactivate") + + def get_virtenv(self): + cwd =3D os.getcwd() + + activates =3D [] + + # Add all sphinx prefixes with possible version numbers + for p in self.virtenv_prefix: + activates +=3D glob(f"{cwd}/{p}[0-9]*/bin/activate") + + activates.sort(reverse=3DTrue, key=3Dstr.lower) + + # Place sphinx_latest first, if it exists + for p in self.virtenv_prefix: + activates =3D glob(f"{cwd}/{p}*latest/bin/activate") + activat= es + + ver =3D (0, 0, 0) + for f in activates: + # Discard too old Sphinx virtual environments + match =3D re.search(r"(\d+)\.(\d+)\.(\d+)", f) + if match: + ver =3D (int(match.group(1)), int(match.group(2)), int(mat= ch.group(3))) + + if ver < self.min_version: + continue + + sphinx_cmd =3D f.replace("activate", "sphinx-build") + if not os.path.isfile(sphinx_cmd): + continue + + ver =3D self.get_sphinx_version(sphinx_cmd) + + if not ver: + venv_dir =3D f.replace("/bin/activate", "") + print(f"Warning: virtual environment {venv_dir} is not wor= king.\n" \ + "Python version upgrade? Remove it with:\n\n" \ + "\trm -rf {venv_dir}\n\n") + else: + if self.need_sphinx and ver >=3D self.min_version: + return (f, ver) + elif parse_version(ver) > self.cur_version: + return (f, ver) + + return ("", ver) + + def recommend_sphinx_upgrade(self): + # Avoid running sphinx-builds from venv if cur_version is good + if self.cur_version and self.cur_version >=3D RECOMMENDED_VERSION: + self.latest_avail_ver =3D self.cur_version + return None + + # Get the highest version from sphinx_*/bin/sphinx-build and the + # corresponding command to activate the venv/virtenv + self.activate_cmd, self.venv_ver =3D self.get_virtenv() + + # Store the highest version from Sphinx existing virtualenvs + if self.activate_cmd and self.venv_ver > self.cur_version: + self.latest_avail_ver =3D self.venv_ver + else: + if self.cur_version: + self.latest_avail_ver =3D self.cur_version + else: + self.latest_avail_ver =3D (0, 0, 0) + + # As we don't know package version of Sphinx, and there's no + # virtual environments, don't check if upgrades are needed + if not self.virtualenv: + if not self.latest_avail_ver: + return None + + return self.latest_avail_ver + + # Either there are already a virtual env or a new one should be cr= eated + self.need_pip =3D 1 + + if not self.latest_avail_ver: + return None + + # Return if the reason is due to an upgrade or not + if self.latest_avail_ver !=3D (0, 0, 0): + if self.latest_avail_ver < RECOMMENDED_VERSION: + self.rec_sphinx_upgrade =3D 1 + + return self.latest_avail_ver + + def recommend_sphinx_version(self, virtualenv_cmd): + # The logic here is complex, as it have to deal with different ver= sions: + # - minimal supported version; + # - minimal PDF version; + # - recommended version. + # It also needs to work fine with both distro's package and venv/v= irtualenv + + # Version is OK. Nothing to do. + if self.cur_version !=3D (0, 0, 0) and self.cur_version >=3D RECOM= MENDED_VERSION: + return + + if not self.need_sphinx: + # sphinx-build is present and its version is >=3D $min_version + + # only recommend enabling a newer virtenv version if makes sen= se. + if self.latest_avail_ver and self.latest_avail_ver > self.cur_= version: + print("\nYou may also use the newer Sphinx version {self.l= atest_avail_ver} with:") + if f"{self.virtenv_prefix}" in os.getcwd(): + print("\tdeactivate") + print(f"\t. {self.activate_cmd}") + self.deactivate_help() + return + + if self.latest_avail_ver and self.latest_avail_ver >=3D RECOMM= ENDED_VERSION: + return + + if not self.virtualenv: + # No sphinx either via package or via virtenv. As we can't + # Compare the versions here, just return, recommending the + # user to install it from the package distro. + if not self.latest_avail_ver or self.latest_avail_ver =3D=3D (= 0, 0, 0): + return + + # User doesn't want a virtenv recommendation, but he already + # installed one via virtenv with a newer version. + # So, print commands to enable it + if self.latest_avail_ver > self.cur_version: + print("\nYou may also use the Sphinx virtualenv version {s= elf.latest_avail_ver} with:") + if f"{self.virtenv_prefix}" in os.getcwd(): + print("\tdeactivate") + print(f"\t. {self.activate_cmd}") + self.deactivate_help() + return + print("\n") + else: + if self.need_sphinx: + self.need +=3D 1 + + # Suggest newer versions if current ones are too old + if self.latest_avail_ver and self.latest_avail_ver >=3D self.min_v= ersion: + if self.latest_avail_ver >=3D RECOMMENDED_VERSION: + print("\nNeed to activate Sphinx (version {self.latest_ava= il_ver}) on virtualenv with:") + print(f"\t. {self.activate_cmd}") + self.deactivate_help() + return + + # Version is above the minimal required one, but may be + # below the recommended one. So, print warnings/notes + if self.latest_avail_ver < RECOMMENDED_VERSION: + print(f"Warning: It is recommended at least Sphinx version= {RECOMMENDED_VERSION}.") + + # At this point, either it needs Sphinx or upgrade is recommended, + # both via pip + + if self.rec_sphinx_upgrade: + if not self.virtualenv: + print("Instead of install/upgrade Python Sphinx pkg, you c= ould use pip/pypi with:\n\n") + else: + print("To upgrade Sphinx, use:\n\n") + else: + print("\nSphinx needs to be installed either:\n1) via pip/pypi= with:\n") + + self.python_cmd =3D self.find_python_no_venv() + + print(f"\t{virtualenv_cmd} {self.virtenv_dir}") + print(f"\t. {self.virtenv_dir}/bin/activate") + print(f"\tpip install -r {self.requirement_file}") + self.deactivate_help() + + print("\n2) As a package with:") + + old_need =3D self.need + old_optional =3D self.optional + self.missing =3D {} + self.pdf =3D False + self.optional =3D 0 + self.install =3D "" + old_verbose =3D self.verbose_warn_install + self.verbose_warn_install =3D 0 + + self.add_package("python-sphinx", 0) + + self.check_distros() + + self.need =3D old_need + self.optional =3D old_optional + self.verbose_warn_install =3D old_verbose + + print("\n" \ + " Please note that Sphinx >=3D 3.0 will currently produce= false-positive\n" \ + " warning when the same name is used for more than one typ= e (functions,\n" \ + " structs, enums,...). This is known Sphinx bug. For more = details, see:\n" \ + "\thttps://github.com/sphinx-doc/sphinx/pull/8313") + + def check_needs(self): + self.get_system_release() + + # Check if Sphinx is already accessible from current environment + self.check_sphinx() + + if self.system_release: + print(f"Detected OS: {self.system_release}.") + else: + print("Unknown OS") + if self.cur_version !=3D (0, 0, 0): + ver =3D ver_str(self.cur_version) + print(f"Sphinx version: {ver}\n") + + # FIXME: Check python command line, trying first python3 + self.python_cmd =3D self.which("python3") + if not self.python_cmd: + self.python_cmd =3D self.check_program("python", 0) + + # Check the type of virtual env, depending on Python version + if self.python_cmd: + if self.virtualenv: + try: + result =3D self.run( + [self.python_cmd, "--version"], + capture_output=3DTrue, + text=3DTrue, + check=3DTrue, + ) + + output =3D result.stdout + result.stderr + + match =3D re.search(r"(\d+)\.(\d+)\.", output) + if match: + major =3D int(match.group(1)) + minor =3D int(match.group(2)) + + if major < 3: + sys.exit("Python 3 is required to build the ke= rnel docs") + if major =3D=3D 3 and minor < 3: + self.need_virtualenv =3D True + else: + sys.exit(f"Warning: couldn't identify {self.python= _cmd} version!") + + except subprocess.CalledProcessError as e: + sys.exit(f"Error checking Python version: {e}") + else: + self.add_package("python-sphinx", 0) + + self.venv_ver =3D self.recommend_sphinx_upgrade() + + virtualenv_cmd =3D "" + + if self.need_pip: + # Set virtualenv command line, if python < 3.3 + # FIXME: can be removed as we're now with an upper min require= ment + # but then we need to check python version + if self.need_virtualenv: + virtualenv_cmd =3D self.which("virtualenv-3") + if not virtualenv_cmd: + virtualenv_cmd =3D self.which("virtualenv-3.5") + if not virtualenv_cmd: + self.check_program("virtualenv", 0) + virtualenv_cmd =3D "virtualenv" + else: + virtualenv_cmd =3D f"{self.python_cmd} -m venv" + self.check_python_module("ensurepip", 0) + + # Check for needed programs/tools + self.check_perl_module("Pod::Usage", 0) + self.check_python_module("yaml", 0) + self.check_program("make", 0) + self.check_program("gcc", 0) + self.check_program("dot", 1) + self.check_program("convert", 1) + + if self.pdf: + # Extra PDF files - should use 2 for LaTeX is_optional + self.check_program("xelatex", 2) + self.check_program("rsvg-convert", 2) + self.check_program("latexmk", 2) + + # Do distro-specific checks and output distro-install commands + self.check_distros() + + if not self.python_cmd: + if self.need =3D=3D 1: + sys.exit("Can't build as 1 mandatory dependency is missing= ") + elif self.need: + sys.exit(f"Can't build as {self.need} mandatory dependenci= es are missing") + + # Check if sphinx-build is called sphinx-build-3 + if self.need_symlink: + sphinx_path =3D self.which("sphinx-build-3") + if sphinx_path: + print(f"\tsudo ln -sf {sphinx_path} /usr/bin/sphinx-build\= n") + + self.recommend_sphinx_version(virtualenv_cmd) + print("") + + if not self.optional: + print("All optional dependencies are met.") + + if self.need =3D=3D 1: + sys.exit("Can't build as 1 mandatory dependency is missing") + elif self.need: + sys.exit(f"Can't build as {self.need} mandatory dependencies a= re missing") + + print("Needed package dependencies are met.") + + def get_system_release(self): + """ + Determine the system type. There's no unique way that would work + with all distros with a minimal package install. So, several + methods are used here. + + By default, it will use lsb_release function. If not available, it= will + fail back to reading the known different places where the distro n= ame + is stored. + + Several modern distros now have /etc/os-release, which usually have + a decent coverage. + """ + + if self.which("lsb_release"): + result =3D self.run(["lsb_release", "-d"], capture_output=3DTr= ue, text=3DTrue) + self.system_release =3D result.stdout.replace("Description:", = "").strip() + + release_files =3D [ + "/etc/system-release", + "/etc/redhat-release", + "/etc/lsb-release", + "/etc/gentoo-release", + ] + + if not self.system_release: + for f in release_files: + self.system_release =3D self.catcheck(f) + if self.system_release: + break + + # This seems more common than LSB these days + if not self.system_release: + os_var =3D {} + try: + with open("/etc/os-release", "r", encoding=3D"utf-8") as f: + for line in f: + match =3D re.match(r"^([\w\d\_]+)=3D\"?([^\"]*)\"?= \n", line) + if match: + os_var[match.group(1)] =3D match.group(2) + + self.system_release =3D os_var.get("NAME", "") + if "VERSION_ID" in os_var: + self.system_release +=3D " " + os_var["VERSION_ID"] + elif "VERSION" in os_var: + self.system_release +=3D " " + os_var["VERSION"] + except IOError: + pass + + if not self.system_release: + self.system_release =3D self.catcheck("/etc/issue") + + self.system_release =3D self.system_release.strip() + +DESCRIPTION =3D """ +Process some flags related to Sphinx installation and documentation build. +""" + + +def main(): + parser =3D argparse.ArgumentParser(description=3DDESCRIPTION) + + parser.add_argument( + "--no-virtualenv", + action=3D"store_false", + dest=3D"virtualenv", + help=3D"Recommend installing Sphinx instead of using a virtualenv", + ) + + parser.add_argument( + "--no-pdf", + action=3D"store_false", + dest=3D"pdf", + help=3D"Don't check for dependencies required to build PDF docs", + ) + + parser.add_argument( + "--version-check", + action=3D"store_true", + dest=3D"version_check", + help=3D"If version is compatible, don't check for missing dependen= cies", + ) + + args =3D parser.parse_args() + + checker =3D SphinxDependencyChecker(args) + + checker.check_needs() + + +if __name__ =3D=3D "__main__": + main() --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D2992F83A7; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=UYUSJpjBrvLbwSeLbr9LBdeY+n15XlywEj+LkPt+0lNkaFtdTEAm/1ha/KWH4ZJj+4n3Tslw64FfH4ovJaegIa+SPZFECZKAlCb5bA+BLurcY3ID5hZwTReTelqGsz0gb5Qp7ZC+1PRUmNFzAXUFdqGXYqkcZj9XDRottW5qQKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=kHHUrzrUzCfISUwvoyyC98eBFz5CP0ST0NUYuTddsmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NBlZ73v4k/xWUvTmX1XioDozSFd2YjN3odT71bYmkUS9VMqkYE0P/LEBaWRUweqXWWPfiAeexymfJFhOocgtjlMuopKyTbEL7WND0zrwYOPPN7Nuqbc9sjfHcLUO/6bVxdrVcOtqFRUQlgT1slHc6h+8bo9UIhFl8mPWFcKPVUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C/RuddMX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C/RuddMX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DED01C116B1; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=kHHUrzrUzCfISUwvoyyC98eBFz5CP0ST0NUYuTddsmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C/RuddMXj01aFckxdmu1McLsV4wBlfjaWp3dv90LWm+tMd3Gdej/cR0EcJKUGExch Rgwer0d0WLCI6/UN3RAJXA7H3xvVWYXqOF/qB8p9gQRbLt/oEXv9aEnjTRaIEAng7L RCY2in7h8AK3bMWer6J1RU2+JxFPK9AlWiLTaDpXcV/Q/6i+Km6Ye+qoygL+jPGFpr spTUuHo0F+h/4NQGvsxY0CWNP1K8TNVgYgWJmdKX4VRMEXvINRJn0TCACbzE4+n6dI /U9jw4rGcbYXcR+Vn6bWQgU1TwOLc0LUjj+JIoMeMtxFr0E3qRug8FV/d95rAGXnkx 1fM2z+i5m+rAA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVS-0ibi; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 04/39] scripts: sphinx-pre-install: Make it compatible with Python 3.6 Date: Tue, 12 Aug 2025 17:52:21 +0200 Message-ID: <39d6e27a047bc3cc8208ac5e11fe6ba44faff9c4.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The minimal version requirements we have is 3.9. Yet, the script which detects it is this one. So, let's try supporting an old version here, as we may want to suggest to upgrade Python version to build the docs. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index dcee2181b72f..71d86b230b22 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -115,7 +115,8 @@ class SphinxDependencyChecker: def find_python_no_venv(): # FIXME: does it makes sense now that this script is in Python? =20 - result =3D subprocess.run(["pwd"], capture_output=3DTrue, text=3DT= rue) + result =3D SphinxDependencyChecker.run(["pwd"], capture_output=3DT= rue, + text=3DTrue) cur_dir =3D result.stdout.strip() =20 python_names =3D ["python3", "python"] @@ -135,12 +136,23 @@ class SphinxDependencyChecker: def run(*args, **kwargs): """Excecute a command, hiding its output by default""" =20 - if not kwargs.get('capture_output', False): + capture_output =3D kwargs.pop('capture_output', False) + + if capture_output: + if 'stdout' not in kwargs: + kwargs['stdout'] =3D subprocess.PIPE + if 'stderr' not in kwargs: + kwargs['stderr'] =3D subprocess.PIPE + else: if 'stdout' not in kwargs: kwargs['stdout'] =3D subprocess.DEVNULL if 'stderr' not in kwargs: kwargs['stderr'] =3D subprocess.DEVNULL =20 + # Don't break with older Python versions + if 'text' in kwargs and sys.version_info < (3, 7): + kwargs['universal_newlines'] =3D kwargs.pop('text') + return subprocess.run(*args, **kwargs) =20 # --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4704A2F6592; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=ijBWPhEXx1Vz+Il7V8aT9+J57CEU6gsj4DwIaoyx+qfDRyCTtswLHlz+SrOn58QgbBMlM2aY7rTvYWX81NZHncFHbzWg+UPCVNQ1pKId91LmCswVmCE+sLBtQNclb4US7yApVzo7kpZ2mcy70llKOwB6vmIY4atrPyO5BlzaoR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=xnQ6IjOnGM/7IpW6FAxRYORGqrWYSQqxyC/SU5roPxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bcp/D4YxXa7aHNpGuWHD0QJED5QyiZKgBuKxOEVLqqwQncprXpyXHuFukZjkX9D0LsCTH95BoxOKoekuG3ZHHCx2V6KtgYHwHgs2z47DhbovjNt4a/4/t5rFUsWgphFbwVgSKElu8wAz2/TVkWejr7hibASHfBM02SlIBaHSSOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SkYLY/qq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SkYLY/qq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA0B6C4CEFF; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=xnQ6IjOnGM/7IpW6FAxRYORGqrWYSQqxyC/SU5roPxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SkYLY/qqDhry6CyCAPVo9mPlJfps2zuZr/Ut5NPCengna0/SEhEWEejOdaCmPdBSU eZqs7Rk2LE7BmbVf+f4ukyLhHcjHGFajJlFWaDcDWkrbru+TMZnP5i9mGnjqNWcm4T JOI4/qAZX60g/yHpnOlwrxJVoA0E9mx+X0Y7Q21O/F+091pPL5wobxz0iMrXJHBuhs XtAsluJc4GFiSzI/pqM53mTmkR7wb40ONzq31sYRwH8AmQucAVzTT0btzRwKlekpH/ mmthccgbHaxLWMj4IJC1t1I055vS6c33ldgldHEHbLkanpaygKSEYzyn9ywPKFqi0b he+0Fn2R85ePg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVW-0rGl; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 05/39] scripts: sphinx-pre-install: run on a supported version Date: Tue, 12 Aug 2025 17:52:22 +0200 Message-ID: <76627055a7f82f6a79296ddbd873fa5ac8f82a1d.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The scripts/sphinx-pre-install is used to detect problems at the system environment and adjust it to build the Kernel documentation. If the version is too old, it won't run, though. Check if the version which started the script is valid. If not, seek for a new one that is compatible with documentation build. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 65 ++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 71d86b230b22..3912359d2bae 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -5,6 +5,9 @@ # pylint: disable=3DC0103,C0114,C0115,C0116,C0301 # pylint: disable=3DR0902,R0904,R0912,R0915,R1705,R1710,E1121 =20 +# Note: this script requires at least Python 3.6 to run. +# Don't add changes not compatible with it, it is meant to report +# incompatible python versions. =20 import argparse import os @@ -16,7 +19,6 @@ from glob import glob =20 def parse_version(version): """Convert a major.minor.patch version into a tuple""" -# return tuple(int(x) for x in version.split(".")) =20 =20 @@ -27,6 +29,7 @@ def ver_str(version): =20 =20 RECOMMENDED_VERSION =3D parse_version("3.4.3") +MIN_PYTHON_VERSION =3D parse_version("3.7") =20 =20 class SphinxDependencyChecker: @@ -132,6 +135,65 @@ class SphinxDependencyChecker: # Python not found at the PATH return python_names[-1] =20 + @staticmethod + def get_python_version(cmd): + + result =3D SphinxDependencyChecker.run([cmd, "--version"], + capture_output=3DTrue, text=3D= True) + version =3D result.stdout.strip() + + match =3D re.search(r"(\d+\.\d+\.\d+)", version) + if match: + return parse_version(match.group(1)) + + print(f"Can't parse version {version}") + return (0, 0, 0) + + @staticmethod + def find_python(): + + patterns =3D [ + "python3.[0-9]", + "python3.[0-9][0-9]", + ] + + new_python_cmd =3D None + + # Seek for a python binary newer than MIN_PYTHON_VERSION + for path in os.getenv("PATH", "").split(":"): + for pattern in patterns: + for cmd in glob(os.path.join(path, pattern)): + if os.path.isfile(cmd) and os.access(cmd, os.X_OK): + version =3D SphinxDependencyChecker.get_python_ver= sion(cmd) + if version >=3D MIN_PYTHON_VERSION: + return(cmd) + + @staticmethod + def check_python(): + + cur_ver =3D sys.version_info[:3] + if cur_ver >=3D MIN_PYTHON_VERSION: + return + + python_ver =3D ver_str(cur_ver) + + new_python_cmd =3D SphinxDependencyChecker.find_python() + if not new_python_cmd: + print(f"ERROR: Python version {python_ver} is not spported any= more") + print(f" Can't find a new version. This script may fail") + return + + # Restart script using the newer version + script_path =3D os.path.abspath(sys.argv[0]) + args =3D [new_python_cmd, script_path] + sys.argv[1:] + + print(f"Python {python_ver} not supported. Changing to {new_python= _cmd}") + + try: + os.execv(new_python_cmd, args) + except OSError as e: + sys.exit(f"Failed to restart with {new_python_cmd}: {e}") + @staticmethod def run(*args, **kwargs): """Excecute a command, hiding its output by default""" @@ -1107,6 +1169,7 @@ def main(): =20 checker =3D SphinxDependencyChecker(args) =20 + checker.check_python() checker.check_needs() =20 =20 --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A7B82F659F; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=oGFjv1H0hVFmT2DlIeAORTi68GQBeMN7n1DzOcIpDgNMXKqyBQfBbY8gTBgCZ6fOIVb1Vig5k/ocF2SLStXVsTWqu6XJIaHwlTcPg0SGlEM52nW+s+Bi6Rx/ASGf9CJBASuVFKdJEVBzR4O9PGHBaHYda1aW5JWxM2m0Wt1QArU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=pGT/dJ53lsh8VHk2ntlH7KrRTKY2+y+5ODEQAIhvyXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cL5x5fU2zgV+dgnac80+sLcfmetQM8mv50nt1pK712uY01EkuCBQnG8j76M1IrTHdXVtV8wpZ9Jlc3u0RBDnan6c3nFyGkqBYJHP4WjsqD0w4CMMZzLQPgJHkriTtN8+zpX43HNtvZ276Y+mSb/iCTQmr5kbDJAx1Nw4SLoRcNk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AdCHPJDE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AdCHPJDE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8160C4CEF1; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=pGT/dJ53lsh8VHk2ntlH7KrRTKY2+y+5ODEQAIhvyXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AdCHPJDEq60dZomyyc7UglZUBwAT7hWQlGJg4fyUJyANhZP4GL8+amPtylK9J01y6 SZJHogBtUhXpvZdMyb9Mfwp3mrjgZs2fiBXmuanJ3HHhz0CvLshEZzjZKi7GNLowYD Kabxs0TahdWWlNaWGShOPiw++Gmsut7QgINjMSLHnvs2qzOTKrC1AH2EyV54Mbq9Mi A+ZRw96BfMPhFFuwCx60HiYOjX6ochlrNwxCHE8xkaxbfmpIAJsLT69TbdHy0WpQbx EdLNncMpbVzLHJb4uUBcgLuqjZLFrQ0Vcs70xDKO5SC5+JtHUHMD/RADdLah1g8vnq 8BknR7sADB8lg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVa-0yT2; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 06/39] scripts: sphinx-pre-install: drop obsolete routines Date: Tue, 12 Aug 2025 17:52:23 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 3912359d2bae..b639acd455cc 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -114,27 +114,6 @@ class SphinxDependencyChecker: =20 return None =20 - @staticmethod - def find_python_no_venv(): - # FIXME: does it makes sense now that this script is in Python? - - result =3D SphinxDependencyChecker.run(["pwd"], capture_output=3DT= rue, - text=3DTrue) - cur_dir =3D result.stdout.strip() - - python_names =3D ["python3", "python"] - - for d in os.environ.get("PATH", "").split(":"): - if f"{cur_dir}/sphinx" in d: - continue - - for p in python_names: - if os.access(os.path.join(d, p), os.X_OK): - return os.path.join(d, p) - - # Python not found at the PATH - return python_names[-1] - @staticmethod def get_python_version(cmd): =20 @@ -940,7 +919,7 @@ class SphinxDependencyChecker: else: print("\nSphinx needs to be installed either:\n1) via pip/pypi= with:\n") =20 - self.python_cmd =3D self.find_python_no_venv() + self.python_cmd =3D os.path.abspath(sys.argv[0]) =20 print(f"\t{virtualenv_cmd} {self.virtenv_dir}") print(f"\t. {self.virtenv_dir}/bin/activate") --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6BC62F83BF; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=AyUrxNtOeOkjB7yIUJTUDi/qbZ/oiG8t9FHJso0p0Kz/Pulzofikhm6WiSqfeEfIGZl4CwH3e/gqvJPH2ccF7GFsiF5zkvTADYrRk1DlBupirhiw7NsYIrwr2CSOzOBvZLccQ/OCbDiv/i1UGileqYfrqw+5T8/VoJkDJMz716c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=86v5r7sbZHISneU7QYFPRCO61uPUgFH00hFspW9OHdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eJFedV92HRQPnNb4Z87mGPG9kjDpatJ/6jGwQEIO9sOPQsBkD44IpToQxGrHBodGhMeiaun2UYO+CxYJFLgYRfes+et76q0gabU5wz8eG4VcYJ9YOrsFbxSPbC2BTMpZ4Gnd7J4AXBOeTzyhqfDVBk/egIyW+njw/79UrgML4kw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gP79WxtR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gP79WxtR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC89AC4AF12; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=86v5r7sbZHISneU7QYFPRCO61uPUgFH00hFspW9OHdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gP79WxtRhvbivpB7RHIbwS2m8s/EWrWnvtGngYovDtdeXf4hx4Ofg9/l3KFRjGlKP gjB9Qod+3uzTHQdBvZbBfBFWP5ED4uYK4PX5opC74VyxpY2uU/ebdA16P65Nu7ODp4 77vMW9phjgWL4sCxV77NWDO2NiKokZnMxJC5tT5lUyoPLrXm+883sYmFyrBsdCmnTc 4qRIIbdDvORLZXOHdSML/wq4w8DrH+h0i9t4joP9mTDAgORl+HzleiMOpbRprQf31P v++Fux9cj805JdbYToDB5S65w9PrR8UIH9WqMuw1aYe9uTq1YhX73uIEH/3FcJijJa kajhjoLGPT4dA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVe-15YQ; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 07/39] scripts: sphinx-pre-install: drop support for old virtualenv Date: Tue, 12 Aug 2025 17:52:24 +0200 Message-ID: <31afe394bcfd8f7e450263c1922d2c73b91d36d8.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Up to Python 3.2, the virtual environment were created via virtualenv binary. As we dropped support for such old version, clean up the code. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 69 +++++++++-------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index b639acd455cc..0a73b1b33842 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -80,7 +80,6 @@ class SphinxDependencyChecker: self.need_symlink =3D 0 self.need_sphinx =3D 0 self.need_pip =3D 0 - self.need_virtualenv =3D 0 self.rec_sphinx_upgrade =3D 0 self.verbose_warn_install =3D 1 =20 @@ -919,12 +918,14 @@ class SphinxDependencyChecker: else: print("\nSphinx needs to be installed either:\n1) via pip/pypi= with:\n") =20 - self.python_cmd =3D os.path.abspath(sys.argv[0]) - - print(f"\t{virtualenv_cmd} {self.virtenv_dir}") - print(f"\t. {self.virtenv_dir}/bin/activate") - print(f"\tpip install -r {self.requirement_file}") - self.deactivate_help() + if not virtualenv_cmd: + print(" Currently not possible.\n") + print(" Please upgrade Python to a newer version and run thi= s script again") + else: + print(f"\t{virtualenv_cmd} {self.virtenv_dir}") + print(f"\t. {self.virtenv_dir}/bin/activate") + print(f"\tpip install -r {self.requirement_file}") + self.deactivate_help() =20 print("\n2) As a package with:") =20 @@ -953,6 +954,7 @@ class SphinxDependencyChecker: =20 def check_needs(self): self.get_system_release() + self.python_cmd =3D sys.executable =20 # Check if Sphinx is already accessible from current environment self.check_sphinx() @@ -965,56 +967,21 @@ class SphinxDependencyChecker: ver =3D ver_str(self.cur_version) print(f"Sphinx version: {ver}\n") =20 - # FIXME: Check python command line, trying first python3 - self.python_cmd =3D self.which("python3") - if not self.python_cmd: - self.python_cmd =3D self.check_program("python", 0) - # Check the type of virtual env, depending on Python version - if self.python_cmd: - if self.virtualenv: - try: - result =3D self.run( - [self.python_cmd, "--version"], - capture_output=3DTrue, - text=3DTrue, - check=3DTrue, - ) + virtualenv_cmd =3D None =20 - output =3D result.stdout + result.stderr - - match =3D re.search(r"(\d+)\.(\d+)\.", output) - if match: - major =3D int(match.group(1)) - minor =3D int(match.group(2)) - - if major < 3: - sys.exit("Python 3 is required to build the ke= rnel docs") - if major =3D=3D 3 and minor < 3: - self.need_virtualenv =3D True - else: - sys.exit(f"Warning: couldn't identify {self.python= _cmd} version!") - - except subprocess.CalledProcessError as e: - sys.exit(f"Error checking Python version: {e}") - else: - self.add_package("python-sphinx", 0) + if sys.version_info < MIN_PYTHON_VERSION: + min_ver =3D ver_str(MIN_PYTHON_VERSION) + print(f"ERROR: at least python {min_ver} is required to build = the kernel docs") + self.need_sphinx =3D 1 =20 self.venv_ver =3D self.recommend_sphinx_upgrade() =20 - virtualenv_cmd =3D "" - if self.need_pip: - # Set virtualenv command line, if python < 3.3 - # FIXME: can be removed as we're now with an upper min require= ment - # but then we need to check python version - if self.need_virtualenv: - virtualenv_cmd =3D self.which("virtualenv-3") - if not virtualenv_cmd: - virtualenv_cmd =3D self.which("virtualenv-3.5") - if not virtualenv_cmd: - self.check_program("virtualenv", 0) - virtualenv_cmd =3D "virtualenv" + if sys.version_info < MIN_PYTHON_VERSION: + self.need_pip =3D False + print("Warning: python version is not supported.") + else: virtualenv_cmd =3D f"{self.python_cmd} -m venv" self.check_python_module("ensurepip", 0) --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 471412F2907; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=XRpVE7yB4e0Z4CsghXvrUtFLG/yTFcdVr0uR0N58gBr14S4QJonX73bN7ZWdQWN1wKKBX3ghmKGNvR/Jp6JP9TExMFqD+pDOlTgI2rlMBLVW1LKS8Imk5QjKYp2oKC+zA7nAEr00MGsxYSCEoq0JO4ezUhyIWHxP2R1OuiQaoWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=d4OYIow3OjJEsE2LMoKb03hk1/jC/7h0+7RSb/71xC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mM6/m86vob6qb+XZEcvXHEYPeP9wEWIItWVfQMwaymJPz2dj9Hh1ZPX0gwLTuUd9ueDLg5b9GcdDxDy36z8XReRVaNBk9BeY3ZYDPfVdTCm6vCNpjZn52ROWB4hWaISaEUlJrhVJf67uyIfGPp4cIEW2n6vo/8IaBrWN/hzfcZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V/piWB0h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V/piWB0h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C410CC4CEFD; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=d4OYIow3OjJEsE2LMoKb03hk1/jC/7h0+7RSb/71xC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/piWB0hMGMC1sBe5DyHaYshf7X/mSl8VjLYGoeKH9AgWtppEu5xZQaE7sjHEWW4x y/VW2mNX/hKM6bA4/VG4znCRo31Af1qfd0IURd+K3k4xGbQKpls3ygD4uysuDGnGyL gJB1yr+wT9Gjj+yeRqt0ODWzcQQ8IuSdciATCLTPIWj9bvjWUv27EGKpN00T5XplcF ebP3r3lSFT67PkO1yGBfEbbKlSrltbZWG9k2Lt0dILkcKSif8GAKvl0g1PFbHL5QyZ d6XZn1mJhUJKjzehI5BHU5wk36mW8g4kN9z8MrfGunICgfyRRN1VZ4nXrfiPXFkzXx tah17j+rIZ40Q== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVi-1D9E; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 08/39] scripts: sphinx-pre-install: Address issues with OpenSUSE Leap 15.x Date: Tue, 12 Aug 2025 17:52:25 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" On openSUSE Leap 15.6, which is the current LTS version, has two Sphinx packages. The normal one requires Python 3.6, which we don't support anymore. However, it also has Python 3.11 with a newer Sphinx version (7.2.6). Suggest the newer version: Detected OS: openSUSE Leap 15.6. ERROR: at least python 3.7 is required to build the kernel docs Warning: python version is not supported. Warning: better to also install "convert". Warning: better to also install "dot". ERROR: please install "yaml", otherwise, build won't work. You should run: sudo zypper install --no-recommends ImageMagick graphviz py= thon311-pyyaml Sphinx needs to be installed either: 1) via pip/pypi with: Currently not possible. Please upgrade Python to a newer version and run this script aga= in 2) As a package with: sudo zypper install --no-recommends python311-Sphinx Please note that Sphinx >=3D 3.0 will currently produce false-p= ositive warning when the same name is used for more than one type (funct= ions, structs, enums,...). This is known Sphinx bug. For more details,= see: https://github.com/sphinx-doc/sphinx/pull/8313 Can't build as 2 mandatory dependencies are missing Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 0a73b1b33842..eca42d90ed01 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -556,6 +556,22 @@ class SphinxDependencyChecker: =20 progs["latexmk"] =3D "texlive-latexmk-bin" =20 + match =3D re.search(r"(Leap)\s+(\d+).(\d)", self.system_release) + if match: + rel =3D int(match.group(2)) + + # Leap 15.x uses Python 3.6, which is not compatible with + # the build system anymore. Suggest Python 3.11 + if rel =3D=3D 15: + if not self.which(self.python_cmd): + self.add_package(self.python_cmd, 0) + + progs.update({ + "python-sphinx": "python311-Sphinx", + "virtualenv": "python311-virtualenv", + "yaml": "python311-pyyaml", + }) + # FIXME: add support for installing CJK fonts # # I tried hard, but was unable to find a way to install --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7129E2F83A0; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=WBK8Y+ya/Kxb/ZwqPJPFTmZtpTOAUev4m2kVJe5Gjv8pHbjBl90k48H2EJxPgFiIwmKC/lvYL/Wa2fs+FlzvihVBLvtxr4sGi7fzVNqq4F1qkoZOhJc4GyTnYdP6ms3LeIJT4kP1WVYGC8Dd5O3lrJKj5JcfQTjQAAHHesTJyQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=H6jfXH3dWyR+l6WUYs4k/BA5+/vFZ9seox7HuHh0dvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pXDo4K3c3bObM2uFnKycfVE3Fbl60gAD3kdiX0J2D7cbvApg3kr3a3kC+hzyJKLx9xzUXxHVs0CDeYZKq/0dCmQgjb3OY7midf4Z1INg/5x4HscYXsel1mLJj+Tc0wymv1aI+v6arWC1CihVVS2FGl1A5AGtCKgjDqiWaG82+gk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S0VUbw3w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S0VUbw3w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4591C4AF10; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=H6jfXH3dWyR+l6WUYs4k/BA5+/vFZ9seox7HuHh0dvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0VUbw3wjjIW8Fd8gxZnblWtcviSvwcEtGti25m65ZNUVKInlJu//78y6I4yHM9ch dxI259yaUygrP2+mEkZyBhO0dP5JfW9EJ2Bb3tBZOekm5irBqYdfUgA93Hfp518//1 XbACVFs3LIGF5PrUJnv5IPlQKtTN+2laPI2WDf0x36LLtI5xjbOtvPgtpb2MhrtHNh mQpyUDX3l47d2snxup+AzPOvdVHWjL2zUPTPvGBC8QLzZStw1zToI4jt1cR2uIOZkg 6FnqJcu7l6V0Ql7Y9w6wzr0iDv0AsjprdVjojDJS9pFXt9EBD58So8AdgE0jcS9ho8 HXwF+nwbcXjbw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVm-1KNc; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 09/39] scripts: sphinx-pre-install: fix opensuse Leap hint for PyYAML Date: Tue, 12 Aug 2025 17:52:26 +0200 Message-ID: <0266c5e28e136c62de33d2d7f7d5e69b273e0d01.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" On Leap, the name of the package is python311-PyYAML. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index eca42d90ed01..65438c198674 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -569,7 +569,7 @@ class SphinxDependencyChecker: progs.update({ "python-sphinx": "python311-Sphinx", "virtualenv": "python311-virtualenv", - "yaml": "python311-pyyaml", + "yaml": "python311-PyYAML", }) =20 # FIXME: add support for installing CJK fonts --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C94D2F8BC3; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=eAfTQvAPsl0P85/8YIlNysgLizAEHSsVi/uiT3ye0qK3c3ZRzlq/S5IcfwTTxtkseCBzKF2/cFgH51mvP1vaXhSwPgEhcSp+k5LSyHTMtE1qjFLQRJpHkJxj/u4Smm/KNo+oxXlBVFkJfDceEduMCEI20enz8fUf+Naw+OOFLL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=cob72lTRvAFK2nKnFZHwgao4n+Ti/eTdktqy5wFC7NM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CQXhsMrwkfODqv0s92AQJWi8JBo5SKSd7gDacX4hj+20f38RpRgvkG3ERYFjZo6VFhiT4+eGzVH3p9TDlmxfoe+coF3VuL9zikoLVi7XxuoFRm8cBuwRr0mKJrG5SURfQfeLq/9qaVVa1MqqbF+BBgmb7DIU8kDu65SSlRFE//E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ip4R/w8W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ip4R/w8W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA2EAC113CF; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=cob72lTRvAFK2nKnFZHwgao4n+Ti/eTdktqy5wFC7NM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ip4R/w8WKu4o/Sx7cFm84ltMbnw3oAznk6tLfiWw7QM6ghYHPIJLOTfzUJ9COR21w 1/E/uK23u7V7Oi5jkKdRijdOZLhI2b/X7Bywu39BEfdKiBCC//BO/smwp8kgIlxFcj FLNY2aMT0czPFXx/q+gfAVJRNpTyTzTZFwOK0m7PGIMCOCUQPJIFaoG1pGVc2XE5gT KkHaEtLJ6OrvK8s2Rd3hJSRvKCkmjthUuld4LcDSI1bZTJjduhKzVlOtEWpZDI0SMr JpIsBQIBBxx6WWfgDURHhIdWDoyVUwBI1A0JgTwjEIyJI0z4b4dpdz57YsjKIAb7yJ gczE4r3gj8h1g== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVq-1RSx; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 10/39] scripts: sphinx-pre-install: fix support for gentoo Date: Tue, 12 Aug 2025 17:52:27 +0200 Message-ID: <283987633aae7d99e0eff41e24eb6285c1b6b335.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Some gentoo packages have changes. Fix it. While here, improve emerge portage use logic. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 65438c198674..b793796329c8 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -669,12 +669,13 @@ class SphinxDependencyChecker: =20 def give_gentoo_hints(self): progs =3D { - "convert": "media-gfx/imagemagick", - "dot": "media-gfx/graphviz", - "rsvg-convert": "gnome-base/librsvg", - "virtualenv": "dev-python/virtualenv", - "xelatex": "dev-texlive/texlive-xetex media-fonts/dejavu", - "yaml": "dev-python/pyyaml", + "convert": "media-gfx/imagemagick", + "dot": "media-gfx/graphviz", + "rsvg-convert": "gnome-base/librsvg", + "virtualenv": "dev-python/virtualenv", + "xelatex": "dev-texlive/texlive-xetex media-fonts/dejavu= ", + "yaml": "dev-python/pyyaml", + "python-sphinx": "dev-python/sphinx", } =20 if self.pdf: @@ -699,21 +700,17 @@ class SphinxDependencyChecker: print("You should run:") print("\n") =20 - imagemagick =3D "media-gfx/imagemagick svg png" - cairo =3D "media-gfx/graphviz cairo pdf" - portage_imagemagick =3D "/etc/portage/package.use/imagemagick" - portage_cairo =3D "/etc/portage/package.use/graphviz" =20 - result =3D self.run(["grep", "imagemagick", portage_imagemagick], - stdout=3Dsubprocess.PIPE, text=3DTrue) - if not result.stdout.strip(): - print(f"\tsudo su -c 'echo \"{imagemagick}\" > {portage_imagem= agick}'") + portages =3D [ + "media-gfx/imagemagick", + "media-gfx/graphviz", + ] =20 - result =3D self.run(["grep", "graphviz", portage_cairo], - stdout=3Dsubprocess.PIPE, text=3DTrue) - - if not result.stdout.strip(): - print(f"\tsudo su -c 'echo \"{cairo}\" > {portage_cairo}'") + for p in portages: + result =3D self.run(["grep", p, "/etc/portage/package.use/*"], + stdout=3Dsubprocess.PIPE, text=3DTrue) + if not result.stdout.strip(): + print(f"\tsudo emerge -av1 {p}") =20 print(f"\tsudo emerge --ask {self.install}") =20 --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 711853093B7; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=NERRwJPjC4CIn7rwvhGXOi9FdNu4r8T/0aWB6MTLvNd/TGyb/Yf85g8jExwUa6cYUnWd3aq+nuK6j5zv9WL1PSq6Xx5xm67ubPrdZOCCo9ZvT8P5Qrwv7EOABSM55T2W6GOa9boR7/uO38+P2N7YxUqso6EHPbbvj3myuVc4uFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=RQNr/KzcW0oNe7IfHfuHatT3uQ+/hZf9xD7Hq5Cp2QY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P54t0O9Mv0DaWeyXaRIPxeiOvPmxmQEfE0mIcHzzP/xKUFnDYrgtHT8VDPbYTtjiklC5VgsmkjPlR5jdKO0DTW7Fqa+cjQo36/KTVpP6ToyONYSLmsWQm+ezL6h2AuKcoisiohvMRCygGIEg3kZvm3TEg1xig+qtoViQbejNpVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o2GZoDuR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o2GZoDuR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D004CC4CEFC; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=RQNr/KzcW0oNe7IfHfuHatT3uQ+/hZf9xD7Hq5Cp2QY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o2GZoDuRbAQ7u2QyHRK8Vmxjf4deHBGIjBWGX7aC5XiCFGDBzvlgXefR1zO0FPSLG PqUG6fe8A+9yQozmB9X4KsLf0BnazixETE2qdxifnh7bKE1cyHSsHtrE77kWgLlbkO VX2j+79p5Of+G3rRjKDslnxwLCALO/QUGzXy2rl4ZP81u7NWoqkG3BeK8AlcZ+MTWY IB+6xbm5FHBg305r2zSCLmpvucMDABuZIT9tbHTXCeZ0m6sNivgmv0KoOOQxHHISyQ 3RvMB4w16aJ1/muzJphfAXYKwnTTCfcxmiHxncaABnw6OCIciMX0kYyZLZCM5pm3L4 ZndtLFX6n+m4w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVu-1YZJ; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 11/39] scripts: sphinx-pre-install: Address issues with OpenSUSE Tumbleweed Date: Tue, 12 Aug 2025 17:52:28 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" On Tumbleweed, package names are named after python-313*, as it also has older python versions on it. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index b793796329c8..0e165ad05fdb 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -571,6 +571,14 @@ class SphinxDependencyChecker: "virtualenv": "python311-virtualenv", "yaml": "python311-PyYAML", }) + else: + # Tumbleweed defaults to Python 3.11 + + progs.update({ + "python-sphinx": "python313-Sphinx", + "virtualenv": "python313-virtualenv", + "yaml": "python313-PyYAML", + }) =20 # FIXME: add support for installing CJK fonts # --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A6F82F658F; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=KbfMcWhVqD+rWfuHrNWdhKOduu5Y/Xhr/zbyatkqRBH+2SB/tXkdR0RLMndnrpIvfgissHgOekeNaYrJSF7gU0r237r6f8cui2M1+8aNQSvpeiaQdpbRDB8Cdhcp0UeHuLyHfn+l2zm+Iw+6aZQFnh9EDQI4XM377+eETLMtFAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=oCK6WGvw+7PUuHUA0XAEiLZ3Xl9xo2K88VEoJ8LgJJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxt0BmJfbSlKgK8J6t6dbioyrmI7P/jykG0aSJLiWRFzgZ6yblUm+pv+zyiG48zw16mLPJmrXoKcifNeZj83m12h+uhWKzyKdtNYn8Si0KfNOqaEPCdSEaIhLbUQBzrw81Dw+67y9+4gEiV2A868LwYwHqp+lBf6B7LCGGC+Dt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JH+4l/z5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JH+4l/z5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD125C4CEF8; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=oCK6WGvw+7PUuHUA0XAEiLZ3Xl9xo2K88VEoJ8LgJJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JH+4l/z5Ct4Cwi4pgZhQbwRWJEXYJD/k208XqFAD13vlGnP8nSRMF6wvqWqgfaCuY ZW9hjzhb5C4CX8M38WdqbIoBy5s4C7JnnCWmDe4Em0N+5n9faCVIYdQCurU+4oyt6F bNFlmpixwzifAM5BUGypeRH2mdJ09deA0Xkvf0H1pG2WHmmaMVWXwenNH9uWP/53am NxSGkhJDqwcYHMlR+84aylbnqgWhVDI44mA+IZyPN4D5glfvCZB8HYF99ubHdAJZrP 4PMIkUOERzAf6WaKTgyeAKI9ZwAWfgKiEmn4ol12A1IUv/1veY0I4InwoEQyA7l8ue UtZOp6ub6/s1A== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kVy-1h5Z; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 12/39] scripts: sphinx-pre-install: only show portage hints once Date: Tue, 12 Aug 2025 17:52:29 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" On gentoo, doesn't repeat instructions about how to enable portage. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 0e165ad05fdb..808d31bfa790 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -89,6 +89,9 @@ class SphinxDependencyChecker: self.python_cmd =3D "" self.activate_cmd =3D "" =20 + # Certain hints are meant to be shown only once + self.first_hint =3D True + self.min_version =3D (0, 0, 0) self.cur_version =3D (0, 0, 0) self.latest_avail_ver =3D (0, 0, 0) @@ -714,11 +717,14 @@ class SphinxDependencyChecker: "media-gfx/graphviz", ] =20 - for p in portages: - result =3D self.run(["grep", p, "/etc/portage/package.use/*"], - stdout=3Dsubprocess.PIPE, text=3DTrue) - if not result.stdout.strip(): - print(f"\tsudo emerge -av1 {p}") + if self.first_hint: + for p in portages: + result =3D self.run(["grep", p, "/etc/portage/package.use/= *"], + stdout=3Dsubprocess.PIPE, text=3DTrue) + if not result.stdout.strip(): + print(f"\tsudo emerge -av1 {p}") + + self.first_hint =3D False =20 print(f"\tsudo emerge --ask {self.install}") =20 --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 471BC2F8BC1; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=VQ4OhIZ8QxaE5WJh32PDM9GH6sTHtE3/d3nk6G0ujCaUF0d9CJeDpVBCoe0jOqaOu9KOh21h1fai4RhhRitBBWHym4SgXt29d8j4UUeGsSLyUxUipeNxc8Gs2maC4N2uuQ34pTkCKobMRNFS0SuEX2SYg/JlBxz2VYYdlZBq7Jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=w1TdiGxle94uulUw1dxGBpedHds+Ef+v2jfRhcuJvSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KIx3NrP52N1VURnsiIiis6zKhzSGllJLQ+aLTzRjHAthIeW7hxYB0sI4ur86putNF0ErUg6T9fkuHoXpiLMSNJ7mvEkXKFjiE6okFgwWikUhhvM64oQs+z5mmuJqjkzmgpgzC3RXnE3t5vO3b19PYzXNR4vOC3Dg+B7tRLEcT2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TFcDJW0t; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TFcDJW0t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C426AC4AF0D; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=w1TdiGxle94uulUw1dxGBpedHds+Ef+v2jfRhcuJvSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFcDJW0tfgs2h5PaGsRCQUGd14d8v6kjYggaFA6X9mWsvSWffK1RAIFNmc0g5dnG0 IccqBiNSpYA1VSywNETNg7vGGQ06UQSB6A2YPoPK+Xr6GuX8jJGenJ0Zyx5S5/ljrv 1VfWPvGxVLmNqAE6lPSY1g4/n2WbFKckaUQRmNEEh/IS/V6Co4gB55Jb3BK5QDNicS Sn4adJ34bKsIGuBRVqKy4L7jnwJLWWuee2l8MEzKJbNzTmA+nKjyjVecRts2N1+n/m vll5NrJejWHvAoTPb5JlFStv0SPDi28aFhjy4Et43sddB7WKhenmXEkEcNH55IB/tt a/6Eh1ACav4Tg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kW2-1pPu; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 13/39] scripts: sphinx-pre-install: cleanup rhel support Date: Tue, 12 Aug 2025 17:52:30 +0200 Message-ID: <62fe8ab243ad39f4964f1f74b965e43dc8f10e23.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Rhel < 8.0 is not supported anymore. Drop support for it. Rhel 8 is problematic: at least on the tests I did with a docker repo, it didn't work, but it could be due to the issue that it is actually different than a real One. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 808d31bfa790..42f55e67256d 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -487,15 +487,31 @@ class SphinxDependencyChecker: =20 progs["virtualenv"] =3D "python-virtualenv" =20 - if rel and rel < 8: + if not rel or rel < 8: old =3D 1 self.pdf =3D False =20 - # RHEL 7 is in ELS, currently up to Jun, 2026 + print("ERROR: Distro not supported. Too old?") + return + + # TODO: check if RHEL8 still works. + # On my tests with docker "redhat/ubi8" image, there's no + # python3-sphinx (or similar) package. It comes with Python 3.= 6, + # but there are other python packages over there, so it may be + # possible to work with venv. + + if self.first_hint: + print("Note: RHEL-based distros typically require extra re= positories.\n" \ + "For most, enabling epel and crb are enough:\n" \ + "\tsudo dnf install -y epel-release", \ + "\tsudo dnf config-manager --set-enabled crb\n" \ + "Yet, some may have other required repositories. Tho= se commands could be useful:" \ + "\tsudo dnf repolist all" \ + "\tsudo repoquery --available --info ", + "\tsudo dnf config-manager --set-enabled '*' # enabl= e all - probably not what you want") + + self.first_hint =3D False =20 - print("Note: texlive packages on RHEL/CENTOS <=3D 7 are in= complete. Can't support PDF output") - print("If you want to build PDF, please read:") - print("\thttps://www.systutorials.com/241660/how-to-instal= l-tex-live-on-centos-7-linux/") =20 if self.pdf: pdf_pkgs =3D [ --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7121230E83B; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=FE54RY2nOE/aLp53KExiZ+A13b9yG55j9aK4bv3Ty37Zef5mXxmXrp3AmhMj0xJflarQvBdknB1u8hYn1UPPKJlLC5bmF+Bagy0YYJDJNAhVoCKBjK7Opg6TNZBGHR8fW56mGz4S7pod1xz8ZMtp+CX4dt5IRTTAsHG1/k8ZeOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=HRyoaqgBpGj0yMJpohLVQjmYgGi9rpud//gcUb4ofas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BVYGJE1epv2OmLCm8ReXgbLQDXda81OEhJgbDTLPDwN8j8V+VUAlkmU/LMZniOuFHQIcVBOikGSSyS5Yiz/trmkZXUVdr29D4KLRndG2zOdUFn2pzWFh8TSYWh1/5gfEQ1LUUt6hKlgfSu5/vH/dLfGXjeLHORbzyV8ZnyWYRs4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TNb7H8C5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TNb7H8C5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3CB8C4AF0F; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=HRyoaqgBpGj0yMJpohLVQjmYgGi9rpud//gcUb4ofas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNb7H8C5beQY8DOiQy9XZMW6/Xs+pz/Ftzlcrqu6Yo8ZdKB3foe+Rczw9ZpSM6CJH k9skTAwcfPey60bbJdDfm8dm2tME6/+3xoAfoHEBu0I3Fyc4liuwxa9S57xnkmDIag IkKqbbe5qMbn5vSaj585rbqYIubM+A0DhkKZB0fMHHcnGRhHAyrrWDc4AkPkk6mu7s /KRrdZyvVX4CE9T595JZ6fLyuhoMQ4/jT8m6whAmCM2VYTV03Bc7eryz428uU07pfd xbKEDmS2JD86OKYyFKrtHOU3k/ChYxeszOEf5gMfyfC40XpdRr2vWY0LROwq/jHBnB PL28YPp9EbjHg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kW6-1wrn; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 14/39] scripts: sphinx-pre-install: output Python and docutils version Date: Tue, 12 Aug 2025 17:52:31 +0200 Message-ID: <96142ec916b9064c859b200639c3595115080322.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Specially when debugging issues, knowing the versions is important. Add it to the script output. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 42f55e67256d..de5bcfd052b5 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -154,6 +154,20 @@ class SphinxDependencyChecker: =20 cur_ver =3D sys.version_info[:3] if cur_ver >=3D MIN_PYTHON_VERSION: + ver =3D ver_str(cur_ver) + print(f"Python version: {ver}") + + # This could be useful for debugging purposes + if SphinxDependencyChecker.which("docutils"): + result =3D SphinxDependencyChecker.run(["docutils", "--ver= sion"], + capture_output=3DTrue,= text=3DTrue) + ver =3D result.stdout.strip() + match =3D re.search(r"(\d+\.\d+\.\d+)", ver) + if match: + ver =3D match.group(1) + + print(f"Docutils version: {ver}") + return =20 python_ver =3D ver_str(cur_ver) --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D7E42F83B1; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=ZW0DC2xYHX3OItccQWVKnY9MXg2JxRxZiXqkcGeJiMB1xrMiqs1P8m6THZqa6Ev3XHQJYVC7ucxRJ0/I8pv4pFg3xqQAVuWiNLYGmjsiiukgMfvyapquKZtaQ9mIDrOpXykas7+Yhx+53LTL3WI0UFOhPVlFpm6vNPalCfXCwTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=bF+JnX/ikO/qErwMHl0WDLefh6mCv/QIysVRvZKXcRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rxtZL2BAsf1QYE2JxsK+lA684qwmxKKV1PhOdbI58Fo4LpE6dKzmaKZ2B0ykUQja4Qc9cRgeC3oxa2qLX+uBaXcvra0M77eey4wDqGB5C9LkCyfi+cAjwuvaYMrdy8La9zJJaGaFgETnaUqpyBGHjunFF5USm9XCGRL1zJdWS6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y+w62Pcl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y+w62Pcl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D46F6C4AF11; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=bF+JnX/ikO/qErwMHl0WDLefh6mCv/QIysVRvZKXcRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+w62Pcl0i05qKOqTFFP+s7JJxZl/RYkpHRrUMugH9WUQ4cd7fIIqAMj/kg8eH/bM c2dsE2Ee1YEHUvjDmeg9DdOkQ6ykPPTpjuRgyODB3Fo4r+m1WIqS3hVe74rHeCVMZ8 dVhKk0LURlWZt6W2dxblBPsjpVi/RHPeQBU69Jvrn9sCbgSMNbujdQEEgCFibM4d0T UbVpob1Tsm7bIQs/MCW+vqcxY8cIUIp9ISX7Fovz/K/aeE4U9CXDLoxv5CGJgjIMim hP3yK6ehG3x0F6HafhMpePPzvFGK9uG5tTx08gH5Inc1TetV9pPh8UVAKIPBdzWDy3 t4Va+GPTCuQZQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWA-24Za; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 15/39] scripts: sphinx-pre-install: add a missing f-string marker Date: Tue, 12 Aug 2025 17:52:32 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" I forgot one f-string marker, with turned to be affecting 3 lines, because of cut-and-paste ;-) Use the proper f-string marker to print Sphinx version at the hint lines. Yet, we don't want to print as a tuple, so call ver_str() for it. Ideally, we would be placing it directly at the f-string, but Python 3.6 f-string support was pretty much limited. Only 3.12 (PEP 701) makes it similar to Perl, allowing expressions inside it. It sounds that function call itself was introduced on 3.7. As we explicitly want this one to run on 3.6, as latest Leap comes with it, we can't use function calls on f-string. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index de5bcfd052b5..6a244105f7ef 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -914,12 +914,15 @@ class SphinxDependencyChecker: if self.cur_version !=3D (0, 0, 0) and self.cur_version >=3D RECOM= MENDED_VERSION: return =20 + if self.latest_avail_ver: + latest_avail_ver =3D ver_str(self.latest_avail_ver) + if not self.need_sphinx: # sphinx-build is present and its version is >=3D $min_version =20 # only recommend enabling a newer virtenv version if makes sen= se. if self.latest_avail_ver and self.latest_avail_ver > self.cur_= version: - print("\nYou may also use the newer Sphinx version {self.l= atest_avail_ver} with:") + print(f"\nYou may also use the newer Sphinx version {lates= t_avail_ver} with:") if f"{self.virtenv_prefix}" in os.getcwd(): print("\tdeactivate") print(f"\t. {self.activate_cmd}") @@ -940,7 +943,7 @@ class SphinxDependencyChecker: # installed one via virtenv with a newer version. # So, print commands to enable it if self.latest_avail_ver > self.cur_version: - print("\nYou may also use the Sphinx virtualenv version {s= elf.latest_avail_ver} with:") + print(f"\nYou may also use the Sphinx virtualenv version {= latest_avail_ver} with:") if f"{self.virtenv_prefix}" in os.getcwd(): print("\tdeactivate") print(f"\t. {self.activate_cmd}") @@ -954,7 +957,7 @@ class SphinxDependencyChecker: # Suggest newer versions if current ones are too old if self.latest_avail_ver and self.latest_avail_ver >=3D self.min_v= ersion: if self.latest_avail_ver >=3D RECOMMENDED_VERSION: - print("\nNeed to activate Sphinx (version {self.latest_ava= il_ver}) on virtualenv with:") + print(f"\nNeed to activate Sphinx (version {latest_avail_v= er}) on virtualenv with:") print(f"\t. {self.activate_cmd}") self.deactivate_help() return --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 711102F8BF0; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=CFI1+R61o6+ViIlXvviL5F+dNk3aiCVm7QWif7JXaNPkJnvd+7TlphmgGvF4Ejn/lkR0p1GyCdYijq/8GYNcjspRvVUiyR1N5cdJK4t7PKOhW1ODZlR4jImHxAYX+d7l639uRPHx6lOomyxoES5s2Jxxl0unoiyMD6IxzuhLw20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=ny376t2fqD0GqIIjAOTP7dUiyq0BQJ47NgDRbfadqEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XHZzfch8sYdON8C3adhOJOiSckkPoVGkEw+3C9vzSGEH90GFqiY+hXNvomhTWv2/TZFSxmiavt3afJZ1Vxyga8rIrQ6q6vHiaNVBWdZiUqf1TCzCvBE3RzgZ6WlZPDE0Tc+OeckvShizAHr5UCrGNKg5yhikMJOd6uXfj3ZW7nU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YhrXT25c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YhrXT25c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3C81C116C6; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=ny376t2fqD0GqIIjAOTP7dUiyq0BQJ47NgDRbfadqEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhrXT25cltKKir1fMpjVmF+eoD23lWjYSrhUcn7zIzWk+N1t8OG+oigZvvjQM49Sv q6UHWbbzIWJDgb89gqUECI/TUYDtEzAbJ4OmjyzPCODmJSWXSognVWjz4bFpwaKfEK Te62VpqkmDPHDzZIG16mj4AVW/08iNeCqg74so3tadoV3AjhTAJUeWiHjYR2hwmJLN 1iWiCVZ0yiwaMeyWiTNH20xWUYQxefGUxLoFbNUSa8hW2F2Dh4uOL/AK6I8ZIvSWEb WcDHl6Jx9pFFxv6TUgqoYFnSIFP+MvO1tJiyYv06jbbd+YIlOBdCYgWwdameD7QlVZ cjKf3eiV8LRfA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWE-2D8G; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 16/39] scripts: sphinx-pre-install: fix Leap support for rsvg-convert Date: Tue, 12 Aug 2025 17:52:33 +0200 Message-ID: <6fcc94533d860e2f6f4f2c7d6ceb6cca70f48bb6.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" There is a test logic meant to be for Leap, renaming rsvg-convert package. Well, at least on latest Leap releases, this is wrong, causing install to fail. Drop it. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 6a244105f7ef..6b5f9eda91bb 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -566,10 +566,6 @@ class SphinxDependencyChecker: "yaml": "python3-pyyaml", } =20 - # On Tumbleweed, this package is also named rsvg-convert - if not re.search(r"Tumbleweed", self.system_release): - progs["rsvg-convert"] =3D "rsvg-view" - suse_tex_pkgs =3D [ "texlive-babel-english", "texlive-caption", --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 681F82F8BEB; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=F8+p79BTq6YWcc5nKogtE2p/wVnhH9SWtqR1uelABcDdkOfxtPoQ9hA1ITHWhyCFguKRfL8KFBU6C66JERVEKfulQ0T/h+rNNH9D9Z1ysK1eZXXNHxiCKlk8z4sfIE3cuZucFAsAi5xLRtxUAO+4uq6oD2gzUs6az56Pd6zUJJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=KTpTCCjkRQ7n/04aWXym3yGT7vJ2QtIeN0GnK9dV3AI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pR6BbBD4aSTutM/Q7I8VYWw3v/vS9mSlVO4rbI88QopQjU+9lAHRrVpymOHDEGRgwpMpWDfdThQVc4Q4Z2BaQe/qdFLustDuh9veCamWvjgjSo10+7IEGXYo0MpV8koGYIjMqUGGnJBrxJAzmaPE/xVi+z5wA+s15jf+EmLM/Pg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gDvM2J8n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gDvM2J8n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5CCBC4AF0C; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=KTpTCCjkRQ7n/04aWXym3yGT7vJ2QtIeN0GnK9dV3AI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDvM2J8nBvJryctvpwI1NRYjLOYp37rknbpUpCz8vmOSmn2I8HrillVizXMZtXl8o XusQxEjYTomR668FXvlU/3B6IF8Y5xvJIBZf3wok2d9lQ4BpDPlYWwCYbXKeC+s8UI HGUZ9XfBfx6eFkAhIzRLtjMDM+sdF5nYBak8UEay/uOYbEISyU7kQ5dfzReFkyjgWf Wr1bsay1UlboivWvC+AMbixWowfM57DLPxVKoyuYyzQwuNKhpHnQViO1sfF3MXOCmu Rm0XCzc3182g7m+LxyB7oj6FGGCwvwHiKy2YsGIyvgLTw3tahptOCQQ95Ak8YPzq7C OJbFW61ppGxzQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWI-2K8p; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 17/39] scripts: sphinx-pre-install: fix rhel recomendations Date: Tue, 12 Aug 2025 17:52:34 +0200 Message-ID: <393a299a850ba9d94c6a8965e78db4da2dbf7e37.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 6b5f9eda91bb..1f64909953b9 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -519,9 +519,9 @@ class SphinxDependencyChecker: "For most, enabling epel and crb are enough:\n" \ "\tsudo dnf install -y epel-release", \ "\tsudo dnf config-manager --set-enabled crb\n" \ - "Yet, some may have other required repositories. Tho= se commands could be useful:" \ - "\tsudo dnf repolist all" \ - "\tsudo repoquery --available --info ", + "Yet, some may have other required repositories. Tho= se commands could be useful:\n" \ + "\tsudo dnf repolist all\n" \ + "\tsudo dnf repoquery --available --info \n", "\tsudo dnf config-manager --set-enabled '*' # enabl= e all - probably not what you want") =20 self.first_hint =3D False --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A75C2F659D; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=QSL5BDxBG3O10S0uQsy/D/6sz4YCF+RQ+8eIAMgjkAdUJlCFZ8Vk9JsB06fwLzg3DPrkNdNQTbdPvPQ7SiU920YM9YfiXcRFg0jj/cRCgkeVhFD0G7kIeZy1Ll6V/46XAI749slthUpZTASlQPyBfr5ZvLYwUkGIJFjFE6jaShw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=lubWYVOEybDAGm9ORXVmoDyKTrHZrfWsx56TwRP66U0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HzRz9wc9NuqBQ9JSDjXjmwI+zYKF8eySsSc9RG7bToo8eFNIv8bDtt/eXEIuMDLR7NAPOfLIBjpjECXZQBGXY8Z4i1gHCNVdpieAmjtABstGlYlVaYgiUDv00q/QM+eYzw8BZxCGOTmpFYYOX053cI+vccFFnm5Y97C38qMTgXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vp+oupgx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vp+oupgx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B01B7C4AF09; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=lubWYVOEybDAGm9ORXVmoDyKTrHZrfWsx56TwRP66U0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vp+oupgxm8UgYRAOwSaWBmmuBgju8QMbUrbGh96KGrFtA+Ix5HUKEjKbvJAtQ2Psz 36uRSQl5IyrFp/ypwcssSA0dmHRb5GkehDS+t3rp/7wijzIXxhvUtko8D1e3mARZ/h 5IpXvs7ZD3QbES0lWpIeKNyxsQ7xLVTpcPiOujVG3Mc0tG2iabXod/lgmKC12s/gIP 7Ez/CrD4yz7TM2UNqLx605vP52FJkCn/BqObmjohrwZZ1vF1PTaMskeiKknzVidlOt y7GcfI3e6ikr5wx79GYmh0XtxgjINEgMJrVlTez90xPx/Vt/rCL+Tkh6EVbaSYA5x8 V17dFnt64OQ1A== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWM-2Se0; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 18/39] scripts: sphinx-pre-install: remove Scientific Linux Date: Tue, 12 Aug 2025 17:52:35 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" According with its website: https://scientificlinux.org/ Scientific Linux reached end of life in June 30, 2024. Also, it was based on RHEL 7, which is not compatible with our build system anymore. So, drop support for it. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 1f64909953b9..cd9c83b17971 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -769,7 +769,6 @@ class SphinxDependencyChecker: re.compile("openEuler"): self.give_redhat_hin= ts, re.compile("Oracle Linux Server"): self.give_redhat_hin= ts, re.compile("Rocky Linux"): self.give_redhat_hin= ts, - re.compile("Scientific Linux"): self.give_redhat_hin= ts, re.compile("Springdale Open Enterprise"): self.give_redhat_hin= ts, =20 re.compile("Ubuntu"): self.give_debian_hin= ts, --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFABA2F83D7; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=qQM9Ne0y23uug9CbwD7tRF80APABf07X0rQmFlAE/Lsm7xI/9+jqZYiO3fMDMgZYhRY3pZx4s50K+DK+rVrkMOO6Xi5dwAqxc3QAQbgtY5hJWIhswpBvlMV22w6tzzHiQkTYAxhiXUSRcEeAx8TbQVRJan7tLHKqxYVWq+1TGF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=exdw2BI48vq3oUG1To7cfGu2j5O2HUT3gs88cLp4ySs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rttR24viO/KaYlObMZS7G8Oit2fQwKdMucPh4oEyhaI/eKdv06wyoRF2mKO/QADYSgl2Wn5zF6KBNe3SX5zxinS5ZZiZa+nIaLuOw74S0FQ0bgwioWvOfeliHZ9J5jokArOMXSeewqRgn3St6NoP/6LRI26iFMWcDo4IducW3Bw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eRK+xXeR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eRK+xXeR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC0ACC4AF14; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=exdw2BI48vq3oUG1To7cfGu2j5O2HUT3gs88cLp4ySs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eRK+xXeRjeCuS6e/Cwg9j1dfx7HGtPsjQ0mf1upnbNIJsxpBDHw880j8ui0jEW2uD Lp4MzDvcDb/YU3UXbhH7UVJsh5SbBlGA06iAqStjnZc0gZFVG1WgwNuXaQk9hyq9Dx 3yJR+CpudTFZFaxCI2b3aqCs+3X+UxcSbCmm/VGodsggUKP8F10q4RuAVnU0mqz3vB RfrhUxk5+wptAkt7kcdG6a/Xbl8oqWP6jG+v5wgnEq0esUf8FNzaNlYVztJiZ29eJk 3jGCSi50/1vvFWqI4iRZ933OpLUHJ/9hr1HFzo2rb9KBX/Lvo1nRUApjB0opo7hrSb FFRp5gCAy+hTA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWQ-2aOx; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 19/39] scripts: sphinx-pre-install: improve Gentoo package deps logic Date: Tue, 12 Aug 2025 17:52:36 +0200 Message-ID: <365fe5e7d568da932dcffde65f48f2c1256cb773.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" It took me a lot of time, but I guess understand now what it takes to install a package on Gentoo. Handling dependencies is a nightmare, as Gentoo refuses to emerge some packages if there's no package.use file describing them. To make it worse, compilation flags shall also be present there for some packages. If USE is not perfect, error/warning messages like those are shown: gnome-base/librsvg dev-texlive/texlive-xetex media-fonts/dejavu dev-pytho= n/pyyaml ... !!! The following binary packages have been ignored due to non matching USE: =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf -python_single_target_python3_13 = qt6 svg =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf python_single_target_python3_12 -= python_single_target_python3_13 qt6 svg =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf qt6 svg =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf -python_single_target_python3_10 = qt6 svg =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf -python_single_target_python3_10 = python_single_target_python3_12 -python_single_target_python3_13 qt6 svg =3Dmedia-fonts/noto-cjk-20190416 X =3Dapp-text/texlive-core-2024-r1 X cjk -xetex =3Dapp-text/texlive-core-2024-r1 X -xetex =3Dapp-text/texlive-core-2024-r1 -xetex =3Ddev-libs/zziplib-0.13.79-r1 sdl If emerge is allowed, it will simply ignore the above packages, creating an incomplete installation, which will later fail when one tries to build docs with images or build PDFs. After the fix, command line commands to produce the needed USE chain will be emitted, if they don't exist yet. sudo su -c 'echo "media-gfx/graphviz" > /etc/portage/package.use/gr= aphviz' sudo su -c 'echo "media-gfx/imagemagick" > /etc/portage/package.use= /imagemagick' sudo su -c 'echo "media-libs/harfbuzz icu" > /etc/portage/package.u= se/media-libs' sudo su -c 'echo "media-fonts/noto-cjk" > /etc/portage/package.use/= media-fonts' sudo su -c 'echo "app-text/texlive-core xetex" > /etc/portage/packa= ge.use/texlive' sudo su -c 'echo "dev-libs/zziplib sdl" > /etc/portage/package.use/= zziblib' The new logic tries to be smart enough to detect for missing files and missing arguments. Yet, as Gentoo seems to require users to manage those package.use files by hand, the logic isn't perfect: users may still need to verify for conflicts on different use files. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 86 +++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 10 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index cd9c83b17971..94f3d2e32fd6 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -737,22 +737,88 @@ class SphinxDependencyChecker: print("You should run:") print("\n") =20 + # Handling dependencies is a nightmare, as Gentoo refuses to emerge + # some packages if there's no package.use file describing them. + # To make it worse, compilation flags shall also be present there + # for some packages. If USE is not perfect, error/warning messages + # like those are shown: + # + # !!! The following binary packages have been ignored due to non= matching USE: + # + # =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf -python_single_target_p= ython3_13 qt6 svg + # =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf python_single_target_py= thon3_12 -python_single_target_python3_13 qt6 svg + # =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf qt6 svg + # =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf -python_single_target_p= ython3_10 qt6 svg + # =3Dmedia-gfx/graphviz-12.2.1-r1 X pdf -python_single_target_p= ython3_10 python_single_target_python3_12 -python_single_target_python3_13 = qt6 svg + # =3Dmedia-fonts/noto-cjk-20190416 X + # =3Dapp-text/texlive-core-2024-r1 X cjk -xetex + # =3Dapp-text/texlive-core-2024-r1 X -xetex + # =3Dapp-text/texlive-core-2024-r1 -xetex + # =3Ddev-libs/zziplib-0.13.79-r1 sdl + # + # And will ignore such packages, installing the remaining ones. Th= at + # affects mostly the image extension and PDF generation. =20 - portages =3D [ - "media-gfx/imagemagick", - "media-gfx/graphviz", - ] + # Package dependencies and the minimal needed args: + portages =3D { + "graphviz": "media-gfx/graphviz", + "imagemagick": "media-gfx/imagemagick", + "media-libs": "media-libs/harfbuzz icu", + "media-fonts": "media-fonts/noto-cjk", + "texlive": "app-text/texlive-core xetex", + "zziblib": "dev-libs/zziplib sdl", + } =20 if self.first_hint: - for p in portages: - result =3D self.run(["grep", p, "/etc/portage/package.use/= *"], - stdout=3Dsubprocess.PIPE, text=3DTrue) - if not result.stdout.strip(): - print(f"\tsudo emerge -av1 {p}") + use_base =3D "/etc/portage/package.use" + files =3D glob(f"{use_base}/*") + + for fname, portage in portages.items(): + install =3D False + + while install =3D=3D False: + if not files: + # No files under package.usage. Install all + install =3D True + break + + args =3D portage.split(" ") + + name =3D args.pop(0) + + cmd =3D ["grep", "-l", "-E", rf"^{name}\b" ] + files + result =3D self.run(cmd, stdout=3Dsubprocess.PIPE, tex= t=3DTrue) + if result.returncode or not result.stdout.strip(): + # File containing portage name not found + install =3D True + break + + # Ensure that needed USE flags are present + if args: + match_fname =3D result.stdout.strip() + with open(match_fname, 'r', encoding=3D'utf8', + errors=3D'backslashreplace') as fp: + for line in fp: + for arg in args: + if arg.startswith("-"): + continue + + if not re.search(rf"\s*{arg}\b", line): + # Needed file argument not found + install =3D True + break + + # Everything looks ok, don't install + break + + # emit a code to setup missing USE + if install: + print(f"\tsudo su -c 'echo \"{portage}\" > {use_base}/= {fname}'") =20 self.first_hint =3D False =20 - print(f"\tsudo emerge --ask {self.install}") + # Now, we can use emerge and let it respect USE + print(f"\tsudo emerge --ask --changed-use --binpkg-respect-use=3Dy= {self.install}") =20 # # Dispatch the check to an os_specific hinter --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A7342F659C; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=sVVMc2EZPlmSSxjm9MoBAPQySpeQ9Tcgv1Z6z2clLcY91wsM3UOkkyZksRG6mFgxsRJFTaO+jmYshwWxQWyYqc5jSmSsb31W7DVNYFbRK2/b5BrKF5TH7wUvxTcrVIDYKCKSqKLoWLfsQFjLMudn2dActizLrSGFq/8IRZri2dI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=F0VIBtxterrSQG9wqzNfarK/AogmBCYnIszdwgzywXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S2TJthHyXOX9Ua6tuWSmYPjtdf7Y8tzonQS8yhnsrjXAx6YGomrVQJlRfg5cDvF5FP8Ef2qFCYUHe3q/2g+/6mr+24blLiFWw50C70nac32cAc5suXsgP2Disvobd+LzBBk3IyeCo8o5Dorw5EsDP8bWinOwruL8jYbf330GzLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XeUJiRb6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XeUJiRb6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B89C7C4CEF6; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=F0VIBtxterrSQG9wqzNfarK/AogmBCYnIszdwgzywXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XeUJiRb6yJo+s7FnM6i9GtC4OxkoRd1tbcLwwG0NyeBCT+xEb1D1YzsLlVDeIdZEI TcpALt3fCLtkDTlQO5uCxdWXmGoRjYgzIGKXzYQJcq6r0eyRQ3uieImIFwcyjivhuh dxrIeRbFpzwCseskvTW0tNlP27cRiD3dsZXpdLWkHL4XvtGQ78hFGqndd48akmRjit UBySO4KyXXfTplPmwKEjSYqPogNhoPjz3AMGv9yZWsAeeYQNPerzE17PrnO8u0cbqP Ga2gmG+s/ZgS2lUaV7ZTMrXjUc8CaZJL+bwAXqCClGoZrAOqxXnqf1HlbZDyiTJnrX UfyqWZVz4zVFw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWU-2hgd; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 20/39] scripts: sphinx-pre-install: fix OpenMandriva support Date: Tue, 12 Aug 2025 17:52:37 +0200 Message-ID: <0b4e7aa88c96e6a5b8f2e6f381b3e21124680d33.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" OpenMandriva Lx 4.3 has different package names for ImageMagick and yaml. Fix them to ensure that system setup will pass. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 94f3d2e32fd6..2f6036eadc94 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -647,6 +647,11 @@ class SphinxDependencyChecker: packager_cmd =3D "dnf install" noto_sans =3D "noto-sans-cjk-fonts" tex_pkgs =3D ["texlive-collection-fontsextra"] + + # Tested on OpenMandriva Lx 4.3 + progs["convert"] =3D "imagemagick" + progs["yaml"] =3D "python-pyyaml" + else: packager_cmd =3D "urpmi" noto_sans =3D "google-noto-sans-cjk-ttc-fonts" --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64C872F8BE8; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=lR03MSif2NrYQj9GJcmt1KfNgzCF4+mjzfFkgvRZOT6TOyphYUmPE+tzGDW3oi0ghk9i8Hzx3XNOxIU4q5xXOQubfZAsa/Ip4SIqgmF2+mru5yrvtgP7st1mnuJS0mFAtx2PoYYDVW+yE9EqhYeYTM9DJjhJe8PVDkGmP8qgwio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=qLTUoIeHx8ybD7DbPrlVFUdn0U//pEmmYDk8jCaRb/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EQoxEX7uQxmT8FgBDb93LKIFRVBAr7zB60BI4xIZyRifJOlzO5CUp5Zcnf+9kZCykJute9HOUQF3bLKCU6ocunQcVjKFMDFT5MoEIpFJ9vwQwu8GK8Ydwwa21svxMdAyDD0Bt0pEnZNNqh2rQ9oAy0Pq/okHZhgQbt/4RFxA6GU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mPKfhhYn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mPKfhhYn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEEACC4CEF9; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=qLTUoIeHx8ybD7DbPrlVFUdn0U//pEmmYDk8jCaRb/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPKfhhYniAUoi3VzM1inuPRpcyjh1ue0mI+Zh9LrYWPx/UL9UrpulXbQ1ZWNrNSSA muQHRobp+QKziVErl6vQveRSyFbnkSIOotnOPrHYYvyk6IsELCuN0qXkaZNtbZIptD Mir4coFf7bI0ZqcoBX5uC26a484sYFOaAZksFEiSfYTm/7F7I3vfMo8i+76TGiIRB9 u0Tci0MG4Q6td21tORIHNt+JG5+9okor72t1Ou7P+gnJHCcy66lZYC9Ijy/QVxdGAi vOf56nnXDstHUGOJ/SYzE3e/QBYkADaXAAg4fIFKNlpUs4KeEbbz5RWeQiNzL6TOTv A/Rs+Fjud0o0w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWY-2q80; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 21/39] scripts: sphinx-pre-install: move package instructions to a new func Date: Tue, 12 Aug 2025 17:52:38 +0200 Message-ID: <4fb2181c960e89774309a833f80209a1a3ab10d2.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Currently, if Python < 3.7, package install will fail. That happens with OpenSuse Leap and RHEL-based ver 8 distros. OpenSuse allows installing Sphinx with Python 3.11, but RHEL-based distros don't. Prepare to recomend only venv on such cases. For now, just split the recomendation on a new function that will check for a paramtere to be called. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 44 +++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 2f6036eadc94..2360ca2ed21c 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -89,6 +89,9 @@ class SphinxDependencyChecker: self.python_cmd =3D "" self.activate_cmd =3D "" =20 + # Some distros may not have a Sphinx shipped package compatible wi= th + # our minimal requirements + self.package_supported =3D True # Certain hints are meant to be shown only once self.first_hint =3D True =20 @@ -969,6 +972,27 @@ class SphinxDependencyChecker: =20 return self.latest_avail_ver =20 + def recommend_package(self): + + print("\n2) As a package with:") + + old_need =3D self.need + old_optional =3D self.optional + self.missing =3D {} + self.pdf =3D False + self.optional =3D 0 + self.install =3D "" + old_verbose =3D self.verbose_warn_install + self.verbose_warn_install =3D 0 + + self.add_package("python-sphinx", 0) + + self.check_distros() + + self.need =3D old_need + self.optional =3D old_optional + self.verbose_warn_install =3D old_verbose + def recommend_sphinx_version(self, virtualenv_cmd): # The logic here is complex, as it have to deal with different ver= sions: # - minimal supported version; @@ -1053,24 +1077,8 @@ class SphinxDependencyChecker: print(f"\tpip install -r {self.requirement_file}") self.deactivate_help() =20 - print("\n2) As a package with:") - - old_need =3D self.need - old_optional =3D self.optional - self.missing =3D {} - self.pdf =3D False - self.optional =3D 0 - self.install =3D "" - old_verbose =3D self.verbose_warn_install - self.verbose_warn_install =3D 0 - - self.add_package("python-sphinx", 0) - - self.check_distros() - - self.need =3D old_need - self.optional =3D old_optional - self.verbose_warn_install =3D old_verbose + if self.package_supported: + self.recommend_package() =20 print("\n" \ " Please note that Sphinx >=3D 3.0 will currently produce= false-positive\n" \ --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66B572F8BEA; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=hFP3mtAhZBGDl+vSw3b0lUO+iv7nsFxdJYYKDHyh6/vvmYuaFPanznuIePCXKMJ/EAxJ+KlZ0liWVSo6Nh6dX4LbnlVqUvOJYbWfWRLs/fjNSv6ZfR4bk9/syWkQXGOSHpi9LpTeDjI9HzN8dEiUeJG6d6lcLbk34drqD85yxTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=vRnsNCgM3YDMxmN+8rNiF2tJ0DjUjMBLbtkTm4kNDsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m3NS4/Frr4zXQIToyI+3jfp9FjAWzD6UN+yWXZ9pps+tdiJ7uVh+07HWaON4Hqro+9sGXpU/Rni7EIbTKnpjGuWTaqpYeeSUn3Ry7CRutKyIPu2MT8khuTVBv7d5kI8ProCygLq1VulEwiMr1IWGaepqwchtTplUsNuZJBRSdLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zg9+phgP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zg9+phgP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B30CCC4AF0B; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=vRnsNCgM3YDMxmN+8rNiF2tJ0DjUjMBLbtkTm4kNDsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zg9+phgPZLhUffMRUl030IJ328z2sfa3qoqxB+/JmkolJDwbax5Di9rzzstuO8nBr mnLVMBbC/ce4olnSO4h9kqbdDXrQiFXginVneHRqf0f5a+yubvA5Ryddv/WU1VHfuf GARm3lIU5SECBI+teXCJF8zT8q0tkJ9KKJgZqKO3jfV8n6YKez6bcA7FspgiuZ61IR sExHOZJvaqhWCiMH1BcTsS2aEqTdpId6DB0EHXr5IlnCzOzse6Sbm30Y5qyB4279qD 47qcMp9v4Muj2mLxT571EzzixWVt1wtyCKi6bUTUF0KGd/5m56z4TrAXfSzsFxh8NI HxFDbdGy1aq/w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWc-2yPm; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 22/39] scripts: sphinx-pre-install: adjust a warning message Date: Tue, 12 Aug 2025 17:52:39 +0200 Message-ID: <74a17edd70364ca623a54b62bd97a344bb474988.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" There is one extra space at the first line. Also, as now we only support Python 3.4+, update the text. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 2360ca2ed21c..365590f81551 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -1081,8 +1081,8 @@ class SphinxDependencyChecker: self.recommend_package() =20 print("\n" \ - " Please note that Sphinx >=3D 3.0 will currently produce= false-positive\n" \ - " warning when the same name is used for more than one typ= e (functions,\n" \ + " Please note that Sphinx currentlys produce false-positiv= e\n" \ + " warnings when the same name is used for more than one ty= pe (functions,\n" \ " structs, enums,...). This is known Sphinx bug. For more = details, see:\n" \ "\thttps://github.com/sphinx-doc/sphinx/pull/8313") =20 --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A78C2F659E; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=C3eQLQ4T2hFmKNEeg4CdZrxVaMlDmZ2HGWhV4u7teHFKohKNSdBvVXXUUG7dy862kZ1GJf16VtJT7n3iROi/hyUc6gJd/+jPKXpARX2KwqMjlBCmtcA4vTHq+3J0OiLqa7VERok0xRfpaXQpGs8c6sK8kU+vM31RlXUIfSEnX/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=tUovukr9LJAZFuTCxPr3I6APWlpK5/pEVeW1gSeYrBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hJSMgRDYyxOqI3vmP/7UjlTAuf4IgCN5L9f8UNbfkznZvni2NeNXGLKCY8UFjZCDGuUUTfmIvjKfNKgNeEXS7cKSBmI4fa0CqgQ2JB0AdEDVgoHu2C6BsbochldqzM9RMHGfi/yrRjR3iWxSEnCpjtn9wcVpaKgecoCKEwIZl0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I/+T373I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I/+T373I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA9BEC4CEF7; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013984; bh=tUovukr9LJAZFuTCxPr3I6APWlpK5/pEVeW1gSeYrBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/+T373IkRxMN4+DbM1srsAKLqJA4EpftaFElQ21Z13GAB1+HutvQICiDJDocfqMF EfS5atY9zpDFPSH6RbYx16uq8cvZsw6BRgQvZJ0kKMA/OCxk5Z2EidulJxmuoIR4u0 aZyLXWeJciCwPkGwTMR2cwtONhoHP7ilJqQ3HQYTjZm3nMBCazgMOX0FZ+nq+6jzNP VwlgcrKRCgs3ju7XbFRVDxA6k++hjNb7Zz8kRk4kGs3P3Rb5ybovsDnu9d0KUkSCrC raV4o0DqUFQ8oy1Idt8IMiO1gr3/WDy30rgT32TgsheX2h+0HfMXy4V8nPTvCgvMXv coIGXToQ8uRnw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWg-35r3; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 23/39] scripts: sphinx-pre-install: better handle Python min version Date: Tue, 12 Aug 2025 17:52:40 +0200 Message-ID: <013aeb848ecc3f6b69b4518cf3d335bd2353b6e1.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Don't do any recommendations about Sphinx install with too old python versions. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 365590f81551..a5c777e529ec 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -92,6 +92,10 @@ class SphinxDependencyChecker: # Some distros may not have a Sphinx shipped package compatible wi= th # our minimal requirements self.package_supported =3D True + + # Recommend a new python version + self.recommend_python =3D None + # Certain hints are meant to be shown only once self.first_hint =3D True =20 @@ -511,11 +515,11 @@ class SphinxDependencyChecker: print("ERROR: Distro not supported. Too old?") return =20 - # TODO: check if RHEL8 still works. - # On my tests with docker "redhat/ubi8" image, there's no - # python3-sphinx (or similar) package. It comes with Python 3.= 6, - # but there are other python packages over there, so it may be - # possible to work with venv. + # RHEL 8 uses Python 3.6, which is not compatible with + # the build system anymore. Suggest Python 3.11 + if rel =3D=3D 8: + self.add_package("python39", 0) + self.recommend_python =3D True =20 if self.first_hint: print("Note: RHEL-based distros typically require extra re= positories.\n" \ @@ -596,6 +600,7 @@ class SphinxDependencyChecker: # the build system anymore. Suggest Python 3.11 if rel =3D=3D 15: if not self.which(self.python_cmd): + self.recommend_python =3D True self.add_package(self.python_cmd, 0) =20 progs.update({ @@ -1000,6 +1005,11 @@ class SphinxDependencyChecker: # - recommended version. # It also needs to work fine with both distro's package and venv/v= irtualenv =20 + if self.recommend_python: + print("\nPython version is incompatible with doc build.\n" \ + "Please upgrade it and re-run.\n") + return + # Version is OK. Nothing to do. if self.cur_version !=3D (0, 0, 0) and self.cur_version >=3D RECOM= MENDED_VERSION: return --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF70A2F83C8; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=gx19QgwZU9n90PSGSOnq2f+g5ILZ4ELSCYkhcA4gMRnhQqcGy/Bjpr1sdlf21woaGCKxDQVbgGJAeNwk4f/s6BvYgqkIIkIDQhmuttQR6fG4R2lTr6M2iRq56kIk1aDVUY9nSEg8xEBjKRJlYPgtTSksLjwx2dF86I2loeK0bFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=fRpeYNnkO/XLm29IsXGOKl1Wayy/ayQJh5RKfx/WcYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ERYR0tzO0fx7rGImiBvvMsgpY1ULran58oc/fD2tFmsYbckA6nJA29+k6HLx1sDe6esfLW4/llfeQ+jzG939WsODLbC+mVWVbTZOoJ2XQm4aK2opLpbthEcU37yBKTAoFI3CnB3tGbxtfp4a3BEQRfEfgvtD42jszHZ2XnaAtQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nh6VbEAk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nh6VbEAk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBF0DC19422; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=fRpeYNnkO/XLm29IsXGOKl1Wayy/ayQJh5RKfx/WcYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nh6VbEAkrpGkiQBmRU7Q1vWCDyxzxBiLDbL6eEKRzd6IwDHyGUuWNC0sxAPppOuUB G7GgcjkfLiMYjLkSkrQG1cXVjX6DDsM9fGtQzfK+8PsSXS9KdmxWkiqV/tVoTs2Duy ZCUWuardoRQ41Y3paTgBFURyEkBXxn1abKCNLU3UQ52L4uRNSf3oSulem+v/4ECLq2 P12j3A+N7gLLxQFy1++645wGgy8MPc6ikKViXlaI0xZB3VHcmoFWZ1e/OsO5rH/QnN 9nJocF8XtTCw7sdQa+GpGvPLXUd4AjdZo+pZ9JjbgrdmljfgO76CTAAC2MsegkpiPc i+kaSTtoAsPuA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWk-3DAF; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 24/39] scripts: sphinx-pre-install: convert is_optional to a class Date: Tue, 12 Aug 2025 17:52:41 +0200 Message-ID: <42290a24f3b1dbea9ebe19747cf5622bb2f2cf5c.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" When is_optional was added in Perl, it was a boolean. With time, it ended becoming a sort of enum, which makes the module harder to maintain. Convert it to a enum-like class and add more options to it. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 192 +++++++++++++++++++++++----------- 1 file changed, 130 insertions(+), 62 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index a5c777e529ec..0963da21c27b 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -32,6 +32,53 @@ RECOMMENDED_VERSION =3D parse_version("3.4.3") MIN_PYTHON_VERSION =3D parse_version("3.7") =20 =20 +class DepType: + + # Internal types of dependencies. + _SYS_TYPE =3D 0 + _PHY_TYPE =3D 1 + _PDF_TYPE =3D 2 + + # Let's define keys as a tuple with the type and mandatory/optional. + # This way, checking for optional or type is easy. + + SYSTEM_MANDATORY =3D (_SYS_TYPE, True) + PYTHON_MANDATORY =3D (_PHY_TYPE, True) + PDF_MANDATORY =3D (_PDF_TYPE, True) + + # Currently we're not using all optional types, but let's keep all + # combinations here, as we may end needing them in the future. Also, + # it allows a name() function that handles all possibilities. + SYSTEM_OPTIONAL =3D (_SYS_TYPE, False) + PYTHON_OPTIONAL =3D (_PHY_TYPE, False) + PDF_OPTIONAL =3D (_PDF_TYPE, True) + + @staticmethod + def name(dtype): + if dtype[0] =3D=3D DepType._SYS_TYPE: + msg =3D "build" + elif dtype[0] =3D=3D DepType._PHY_TYPE: + msg =3D "Python" + else: + msg =3D "PDF" + + if dtype[1]: + return f"ERROR: {msg} mandatory deps missing" + else: + out =3D f"Warning: {msg} optional deps missing" + + @staticmethod + def is_optional(dtype): + return not dtype[1] + + @staticmethod + def is_pdf(dtype): + if (dtype[0] =3D=3D DepType._PDF_TYPE): + return True + + return False + + class SphinxDependencyChecker: # List of required texlive packages on Fedora and OpenSuse texlive =3D { @@ -223,56 +270,68 @@ class SphinxDependencyChecker: # Methods to check if a feature exists # =20 - # Note: is_optional has 3 states: - # - 0: mandatory - # - 1: optional, but nice to have - # - 2: LaTeX optional - pdf builds without it, but may have visual i= mpact - def check_missing(self, progs): - for prog, is_optional in sorted(self.missing.items()): + run =3D {} + + for prog, dtype in sorted(self.missing.items()): # At least on some LTS distros like CentOS 7, texlive doesn't # provide all packages we need. When such distros are # detected, we have to disable PDF output. # # So, we need to ignore the packages that distros would # need for LaTeX to work - if is_optional =3D=3D 2 and not self.pdf: + if DepType.is_pdf(dtype) and not self.pdf: self.optional -=3D 1 continue =20 + if not dtype in run: + run[dtype] =3D [] + + run[dtype].append(prog) + + output_msg =3D "" + + for dtype in sorted(run.keys()): + progs =3D " ".join(run[dtype]) + if self.verbose_warn_install: - if is_optional: - print(f'Warning: better to also install "{prog}".') - else: - print(f'ERROR: please install "{prog}", otherwise, bui= ld won\'t work.') + try: + name =3D DepType.name(dtype) + output_msg +=3D f'{name}:\t{progs}\n' + except KeyError: + raise KeyError(f"ERROR!!!: invalid dtype for {progs}: = {dtype}") =20 - self.install +=3D " " + progs.get(prog, prog) + self.install +=3D " " + progs + + if output_msg: + print(f"\n{output_msg}\n") =20 self.install =3D self.install.lstrip() =20 - def add_package(self, package, is_optional): - self.missing[package] =3D is_optional + def add_package(self, package, dtype): + is_optional =3D DepType.is_optional(dtype) + self.missing[package] =3D dtype if is_optional: self.optional +=3D 1 else: self.need +=3D 1 =20 - def check_missing_file(self, files, package, is_optional): + def check_missing_file(self, files, package, dtype): for f in files: if os.path.exists(f): return - self.add_package(package, is_optional) + self.add_package(package, dtype) =20 - def check_program(self, prog, is_optional): + def check_program(self, prog, dtype): found =3D self.which(prog) if found: return found =20 - self.add_package(prog, is_optional) + self.add_package(prog, dtype) =20 return None =20 - def check_perl_module(self, prog, is_optional): + def check_perl_module(self, prog, dtype): # While testing with lxc download template, one of the # distros (Oracle) didn't have perl - nor even an option to install # before installing oraclelinux-release-el9 package. @@ -281,46 +340,52 @@ class SphinxDependencyChecker: # add it as a mandatory package, as some parts of the doc builder # needs it. if not self.which("perl"): - self.add_package("perl", 0) - self.add_package(prog, is_optional) + self.add_package("perl", DepType.SYSTEM_MANDATORY) + self.add_package(prog, dtype) return =20 try: self.run(["perl", f"-M{prog}", "-e", "1"], check=3DTrue) except subprocess.CalledProcessError: - self.add_package(prog, is_optional) + self.add_package(prog, dtype) =20 - def check_python_module(self, module, is_optional): - # FIXME: is it needed at the Python version? Maybe due to venv? - if not self.python_cmd: - return + def check_python_module(self, module, is_optional=3DFalse): + if is_optional: + dtype =3D DepType.PYTHON_OPTIONAL + else: + dtype =3D DepType.PYTHON_MANDATORY =20 try: self.run([self.python_cmd, "-c", f"import {module}"], check=3D= True) except subprocess.CalledProcessError: - self.add_package(module, is_optional) + self.add_package(module, dtype) =20 - def check_rpm_missing(self, pkgs, is_optional): + def check_rpm_missing(self, pkgs, dtype): for prog in pkgs: try: self.run(["rpm", "-q", prog], check=3DTrue) except subprocess.CalledProcessError: - self.add_package(prog, is_optional) + self.add_package(prog, dtype) =20 - def check_pacman_missing(self, pkgs, is_optional): + def check_pacman_missing(self, pkgs, dtype): for prog in pkgs: try: self.run(["pacman", "-Q", prog], check=3DTrue) except subprocess.CalledProcessError: - self.add_package(prog, is_optional) + self.add_package(prog, dtype) + + def check_missing_tex(self, is_optional=3DFalse): + if is_optional: + dtype =3D DepType.PDF_OPTIONAL + else: + dtype =3D DepType.PDF_MANDATORY =20 - def check_missing_tex(self, is_optional): kpsewhich =3D self.which("kpsewhich") for prog, package in self.texlive.items(): =20 # If kpsewhich is not there, just add it to deps if not kpsewhich: - self.add_package(package, is_optional) + self.add_package(package, dtype) continue =20 # Check if the package is needed @@ -331,11 +396,11 @@ class SphinxDependencyChecker: =20 # Didn't find. Add it if not result.stdout.strip(): - self.add_package(package, is_optional) + self.add_package(package, dtype) =20 except subprocess.CalledProcessError: # kpsewhich returned an error. Add it, just in case - self.add_package(package, is_optional) + self.add_package(package, dtype) =20 def get_sphinx_fname(self): if "SPHINXBUILD" in os.environ: @@ -446,9 +511,9 @@ class SphinxDependencyChecker: } =20 for package, files in pdf_pkgs.items(): - self.check_missing_file(files, package, 2) + self.check_missing_file(files, package, DepType.PDF_MANDAT= ORY) =20 - self.check_program("dvipng", 2) + self.check_program("dvipng", DepType.PDF_MANDATORY) =20 self.check_missing(progs) =20 @@ -518,7 +583,7 @@ class SphinxDependencyChecker: # RHEL 8 uses Python 3.6, which is not compatible with # the build system anymore. Suggest Python 3.11 if rel =3D=3D 8: - self.add_package("python39", 0) + self.add_package("python39", DepType.SYSTEM_MANDATORY) self.recommend_python =3D True =20 if self.first_hint: @@ -540,13 +605,13 @@ class SphinxDependencyChecker: "/usr/share/fonts/google-noto-sans-cjk-fonts/NotoSansCJK-R= egular.ttc", ] =20 - self.check_missing_file(pdf_pkgs, noto_sans_redhat, 2) + self.check_missing_file(pdf_pkgs, noto_sans_redhat, DepType.PD= F_MANDATORY) =20 if not old: - self.check_rpm_missing(fedora26_opt_pkgs, 2) - self.check_rpm_missing(fedora_tex_pkgs, 2) + self.check_rpm_missing(fedora26_opt_pkgs, DepType.PDF_MAND= ATORY) + self.check_rpm_missing(fedora_tex_pkgs, DepType.PDF_MANDAT= ORY) =20 - self.check_missing_tex(2) + self.check_missing_tex() =20 self.check_missing(progs) =20 @@ -601,7 +666,7 @@ class SphinxDependencyChecker: if rel =3D=3D 15: if not self.which(self.python_cmd): self.recommend_python =3D True - self.add_package(self.python_cmd, 0) + self.add_package(self.python_cmd, DepType.SYSTEM_MANDA= TORY) =20 progs.update({ "python-sphinx": "python311-Sphinx", @@ -623,9 +688,9 @@ class SphinxDependencyChecker: # "Noto Sans CJK SC" on openSUSE =20 if self.pdf: - self.check_rpm_missing(suse_tex_pkgs, 2) + self.check_rpm_missing(suse_tex_pkgs, DepType.PDF_MANDATORY) if self.pdf: - self.check_missing_tex(2) + self.check_missing_tex() self.check_missing(progs) =20 if not self.need and not self.optional: @@ -672,8 +737,8 @@ class SphinxDependencyChecker: "/usr/share/fonts/TTF/NotoSans-Regular.ttf", ] =20 - self.check_missing_file(pdf_pkgs, noto_sans, 2) - self.check_rpm_missing(tex_pkgs, 2) + self.check_missing_file(pdf_pkgs, noto_sans, DepType.PDF_MANDA= TORY) + self.check_rpm_missing(tex_pkgs, DepType.PDF_MANDATORY) =20 self.check_missing(progs) =20 @@ -701,7 +766,7 @@ class SphinxDependencyChecker: ] =20 if self.pdf: - self.check_pacman_missing(archlinux_tex_pkgs, 2) + self.check_pacman_missing(archlinux_tex_pkgs, DepType.PDF_MAND= ATORY) =20 self.check_missing_file( ["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], @@ -739,7 +804,7 @@ class SphinxDependencyChecker: ], } for package, files in pdf_pkgs.items(): - self.check_missing_file(files, package, 2) + self.check_missing_file(files, package, DepType.PDF_MANDAT= ORY) =20 self.check_missing(progs) =20 @@ -878,7 +943,7 @@ class SphinxDependencyChecker: # progs =3D {"sphinx-build": "sphinx"} if self.pdf: - self.check_missing_tex(2) + self.check_missing_tex() =20 self.check_missing(progs) =20 @@ -990,7 +1055,7 @@ class SphinxDependencyChecker: old_verbose =3D self.verbose_warn_install self.verbose_warn_install =3D 0 =20 - self.add_package("python-sphinx", 0) + self.add_package("python-sphinx", DepType.PYTHON_MANDATORY) =20 self.check_distros() =20 @@ -1010,6 +1075,7 @@ class SphinxDependencyChecker: "Please upgrade it and re-run.\n") return =20 + # Version is OK. Nothing to do. if self.cur_version !=3D (0, 0, 0) and self.cur_version >=3D RECOM= MENDED_VERSION: return @@ -1128,21 +1194,23 @@ class SphinxDependencyChecker: =20 else: virtualenv_cmd =3D f"{self.python_cmd} -m venv" - self.check_python_module("ensurepip", 0) + self.check_python_module("ensurepip") =20 # Check for needed programs/tools - self.check_perl_module("Pod::Usage", 0) - self.check_python_module("yaml", 0) - self.check_program("make", 0) - self.check_program("gcc", 0) - self.check_program("dot", 1) - self.check_program("convert", 1) + self.check_perl_module("Pod::Usage", DepType.SYSTEM_MANDATORY) + + self.check_program("make", DepType.SYSTEM_MANDATORY) + self.check_program("gcc", DepType.SYSTEM_MANDATORY) + + self.check_program("dot", DepType.SYSTEM_OPTIONAL) + self.check_program("convert", DepType.SYSTEM_OPTIONAL) + + self.check_python_module("yaml") =20 if self.pdf: - # Extra PDF files - should use 2 for LaTeX is_optional - self.check_program("xelatex", 2) - self.check_program("rsvg-convert", 2) - self.check_program("latexmk", 2) + self.check_program("xelatex", DepType.PDF_MANDATORY) + self.check_program("rsvg-convert", DepType.PDF_MANDATORY) + self.check_program("latexmk", DepType.PDF_MANDATORY) =20 # Do distro-specific checks and output distro-install commands self.check_distros() --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9B72F83AC; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=cKpHpc3FSYEB8iKgs4ATh4f1XE8wJXJ+OpnY0ZoZQFPqAa058VyBYyx0f9V6BbE/jCjiDnQM+DTjhGA6UICX8K+wunJw4wNL1H7Z0ZUc5A4Z5koKunKRI3bmdeuEggj4jB2bRj6lpE1XFJmeFXEhwsAoplKk1ns0Q29Nq5Ew13s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=WIW4xmrBDrTW4s4+RAhMaPsZsgGw9ZJA1kTCbhssfL0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pQIVDEOi4Gct1OREdKni3uZpm0xAhlpHSS3TT2/GnVUn2L7bpO2zbnpXt4O+Q8NHD6VAgpFiR5BP8hSXw51ecRafh8TSAQyyZgkiNb1ef9EEMWRm4ZI1XtoHYEt+5TmBW/XcaYXuGSHzB1Gv1akGxo+nKlx77WPADIoX3WNRbvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CpgghlEw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CpgghlEw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F06EDC2BC87; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=WIW4xmrBDrTW4s4+RAhMaPsZsgGw9ZJA1kTCbhssfL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CpgghlEwndxcgRLA+ym40cijs9ihpb5NSiq4AKsyk3H2YDcIEwveVKYre3g4EdjJp UXqisr+kF71p4iax7hGPNyY07oP0b957VRMWefVgWVr+QI3HYw28INhk45KDjzuY7I TVWTb8XOV1nCaukaVG42vPkH1DJbu0BLwEtNJcwHOtpT+ugxdlHZQK2fHAyH4FzKC6 CD1HkVJI4ifqfqUyX/KDZwGCGndoNEfoyhONBVGFpc8NVw2cFZxWQC+u7evYcJS6xa bbyvov5wJDWqH/ZZG1S4RrWAE/ywuhrXaFb64WZBViMGwFnWNBP88Q5AfJ8CDx712C AUQVCulr/hGfg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWo-3KYY; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 25/39] scripts: sphinx-pre-install: better handle RHEL-based distros Date: Tue, 12 Aug 2025 17:52:42 +0200 Message-ID: <4d1b27d3a381f011e150bb50176babba83af9e1a.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Better implement support for RHEL-based distros. While here, get rid of a Fedora 28 support which cause troubles with server distros. Also, get rid of yum, as RHEL8 already suppords dnf, and this is not the minimal version we may still support. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 0963da21c27b..592223fa686f 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -536,10 +536,6 @@ class SphinxDependencyChecker: "yaml": "python3-pyyaml", } =20 - fedora26_opt_pkgs =3D [ - "graphviz-gd", # Fedora 26: needed for PDF support - ] - fedora_tex_pkgs =3D [ "dejavu-sans-fonts", "dejavu-sans-mono-fonts", @@ -549,9 +545,8 @@ class SphinxDependencyChecker: "texlive-xecjk", ] =20 - old =3D 0 + fedora =3D False rel =3D None - pkg_manager =3D "dnf" =20 match =3D re.search(r"(release|Linux)\s+(\d+)", self.system_releas= e) if match: @@ -559,12 +554,12 @@ class SphinxDependencyChecker: =20 if not rel: print("Couldn't identify release number") - old =3D 1 self.pdf =3D False elif re.search("Fedora", self.system_release): # Fedora 38 and upper use this CJK font =20 noto_sans_redhat =3D "google-noto-sans-cjk-fonts" + fedora =3D True else: # Almalinux, CentOS, RHEL, ... =20 @@ -574,9 +569,6 @@ class SphinxDependencyChecker: progs["virtualenv"] =3D "python-virtualenv" =20 if not rel or rel < 8: - old =3D 1 - self.pdf =3D False - print("ERROR: Distro not supported. Too old?") return =20 @@ -607,11 +599,16 @@ class SphinxDependencyChecker: =20 self.check_missing_file(pdf_pkgs, noto_sans_redhat, DepType.PD= F_MANDATORY) =20 - if not old: - self.check_rpm_missing(fedora26_opt_pkgs, DepType.PDF_MAND= ATORY) - self.check_rpm_missing(fedora_tex_pkgs, DepType.PDF_MANDAT= ORY) + self.check_rpm_missing(fedora_tex_pkgs, DepType.PDF_MANDATORY) + + self.check_missing_tex(DepType.PDF_MANDATORY) + + # There's no texlive-ctex on RHEL 8 repositories. This will + # likely affect CJK pdf build only. + if not fedora and rel =3D=3D 8: + if "texlive-ctex" in self.missing: + del self.missing["texlive-ctex"] =20 - self.check_missing_tex() =20 self.check_missing(progs) =20 @@ -621,11 +618,7 @@ class SphinxDependencyChecker: if self.verbose_warn_install: print("You should run:") =20 - if old: - # dnf is there since Fedora 18+ and RHEL 8 - pkg_manager =3D "yum" - - print(f"\n\tsudo {pkg_manager} install -y {self.install}") + print(f"\n\tsudo dnf install -y {self.install}") =20 def give_opensuse_hints(self): progs =3D { --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C741C2F83D0; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=OSetleQodWPHsnQcpfc7H4Wl/TfwjhAijkcBCfQvisGMnA1nnfZN85S+1UyNEdAp6igoEp6AhtuEgFEYI5Gjy2L6+1nr3lIsRaS7MxlJcjRUTGnshe3xM0s7+FZFr50D5ndHk0uQ1zS6fp4k5uvPQL3Ylgr5bIOXAgWLajbCySc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=v9jIleugXSCkoscKq7k8sKkTguOHMqZDPPqrz4NbqJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CteRG/I0eWgrD8hyIWzcAHMwNhefwPXOb4du+4CeYTwiW8lgzG7jf6vF2YOzahhw+J6gIRt/hIf7mCJT3S1VMEHkpY64JDTLMFUTq5H3MisWaQ6LUEmunPFKiCQp7K+tK7HQ/mx/IuhmhT8g5el68ENQ2jMbvpNmAaRewkofH/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dwdn2SM6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dwdn2SM6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F15D9C4AF19; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=v9jIleugXSCkoscKq7k8sKkTguOHMqZDPPqrz4NbqJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dwdn2SM647m6y9Bh92VgQGkR/6hUzD1hvHea5N2EDFbvY61mep531p7IyQZ1dT2Zk /z1YQK+f2XTupZfbZemhJlDXk4ZI4F4/kjF8PlKBeBSAADIthHXau4T+TXB4Ju8cft iq5BbKcObujd/WYwCDzSArUjmByTuxud+7EShi5f0ef30ZcT6rOvJD9nM6NZgZYBjs Wb1oendnuC53Rn7wnLDLKemJ/7sgj7QHg5ZUXqxLq9cmK+Dy0tM+UZ+5HDKbTMIRLi oVQixXEtk9DosHxHkUgUnG0YqKfA9XqXQtJeswJbjvWBp5sMOFyf3q7xAzRkCxiNs5 M29JXpeL35Y+w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWs-3SOH; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 26/39] scripts: sphinx-pre-install: move missing logic to a separate class Date: Tue, 12 Aug 2025 17:52:43 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Better manage dependencies by placing them on a distro-independent class. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 251 +++++++++++++++++++--------------- 1 file changed, 138 insertions(+), 113 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 592223fa686f..47dce1fcddfb 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -32,7 +32,7 @@ RECOMMENDED_VERSION =3D parse_version("3.4.3") MIN_PYTHON_VERSION =3D parse_version("3.7") =20 =20 -class DepType: +class DepManager: =20 # Internal types of dependencies. _SYS_TYPE =3D 0 @@ -53,11 +53,18 @@ class DepType: PYTHON_OPTIONAL =3D (_PHY_TYPE, False) PDF_OPTIONAL =3D (_PDF_TYPE, True) =20 + def __init__(self, pdf): + self.missing =3D {} + self.run =3D {} + self.need =3D 0 + self.optional =3D 0 + self.pdf =3D pdf + @staticmethod def name(dtype): - if dtype[0] =3D=3D DepType._SYS_TYPE: + if dtype[0] =3D=3D DepManager._SYS_TYPE: msg =3D "build" - elif dtype[0] =3D=3D DepType._PHY_TYPE: + elif dtype[0] =3D=3D DepManager._PHY_TYPE: msg =3D "Python" else: msg =3D "PDF" @@ -73,11 +80,75 @@ class DepType: =20 @staticmethod def is_pdf(dtype): - if (dtype[0] =3D=3D DepType._PDF_TYPE): + if (dtype[0] =3D=3D DepManager._PDF_TYPE): return True =20 return False =20 + def add_package(self, package, dtype): + is_optional =3D DepManager.is_optional(dtype) + self.missing[package] =3D dtype + if is_optional: + self.optional +=3D 1 + else: + self.need +=3D 1 + + def del_package(self, package): + if package in self.missing: + del self.missing[package] + + def clear_deps(self): + """ + Clear dependencies without changing needed/optional. + + This is an ackward way to have a separate section to recommend + a package after system main dependencies. + + TODO: rework the logic to prevent needing it + """ + + self.missing =3D {} + + def check_missing(self, progs): + self.run =3D {} + + for prog, dtype in sorted(self.missing.items()): + # At least on some LTS distros like CentOS 7, texlive doesn't + # provide all packages we need. When such distros are + # detected, we have to disable PDF output. + # + # So, we need to ignore the packages that distros would + # need for LaTeX to work + if DepManager.is_pdf(dtype) and not self.pdf: + self.optional -=3D 1 + continue + + if not dtype in self.run: + self.run[dtype] =3D [] + + self.run[dtype].append(progs.get(prog, prog)) + + install =3D [] + for dtype in self.run.keys(): + install +=3D self.run[dtype] + + return " ".join(sorted(set(install))) + + def warn_install(self): + + output_msg =3D "" + + for dtype in sorted(self.run.keys()): + progs =3D " ".join(sorted(set(self.run[dtype]))) + + try: + name =3D DepManager.name(dtype) + output_msg +=3D f'{name}:\t{progs}\n' + except KeyError: + raise KeyError(f"ERROR!!!: invalid dtype for {progs}: {dty= pe}") + + if output_msg: + print(f"\n{output_msg}\n") =20 class SphinxDependencyChecker: # List of required texlive packages on Fedora and OpenSuse @@ -120,10 +191,8 @@ class SphinxDependencyChecker: self.virtualenv =3D args.virtualenv self.version_check =3D args.version_check =20 - self.missing =3D {} + self.deps =3D DepManager(self.pdf) =20 - self.need =3D 0 - self.optional =3D 0 self.need_symlink =3D 0 self.need_sphinx =3D 0 self.need_pip =3D 0 @@ -270,64 +339,18 @@ class SphinxDependencyChecker: # Methods to check if a feature exists # =20 - def check_missing(self, progs): - run =3D {} - - for prog, dtype in sorted(self.missing.items()): - # At least on some LTS distros like CentOS 7, texlive doesn't - # provide all packages we need. When such distros are - # detected, we have to disable PDF output. - # - # So, we need to ignore the packages that distros would - # need for LaTeX to work - if DepType.is_pdf(dtype) and not self.pdf: - self.optional -=3D 1 - continue - - if not dtype in run: - run[dtype] =3D [] - - run[dtype].append(prog) - - output_msg =3D "" - - for dtype in sorted(run.keys()): - progs =3D " ".join(run[dtype]) - - if self.verbose_warn_install: - try: - name =3D DepType.name(dtype) - output_msg +=3D f'{name}:\t{progs}\n' - except KeyError: - raise KeyError(f"ERROR!!!: invalid dtype for {progs}: = {dtype}") - - self.install +=3D " " + progs - - if output_msg: - print(f"\n{output_msg}\n") - - self.install =3D self.install.lstrip() - - def add_package(self, package, dtype): - is_optional =3D DepType.is_optional(dtype) - self.missing[package] =3D dtype - if is_optional: - self.optional +=3D 1 - else: - self.need +=3D 1 - def check_missing_file(self, files, package, dtype): for f in files: if os.path.exists(f): return - self.add_package(package, dtype) + self.deps.add_package(package, dtype) =20 def check_program(self, prog, dtype): found =3D self.which(prog) if found: return found =20 - self.add_package(prog, dtype) + self.deps.add_package(prog, dtype) =20 return None =20 @@ -340,52 +363,52 @@ class SphinxDependencyChecker: # add it as a mandatory package, as some parts of the doc builder # needs it. if not self.which("perl"): - self.add_package("perl", DepType.SYSTEM_MANDATORY) - self.add_package(prog, dtype) + self.deps.add_package("perl", DepManager.SYSTEM_MANDATORY) + self.deps.add_package(prog, dtype) return =20 try: self.run(["perl", f"-M{prog}", "-e", "1"], check=3DTrue) except subprocess.CalledProcessError: - self.add_package(prog, dtype) + self.deps.add_package(prog, dtype) =20 def check_python_module(self, module, is_optional=3DFalse): if is_optional: - dtype =3D DepType.PYTHON_OPTIONAL + dtype =3D DepManager.PYTHON_OPTIONAL else: - dtype =3D DepType.PYTHON_MANDATORY + dtype =3D DepManager.PYTHON_MANDATORY =20 try: self.run([self.python_cmd, "-c", f"import {module}"], check=3D= True) except subprocess.CalledProcessError: - self.add_package(module, dtype) + self.deps.add_package(module, dtype) =20 def check_rpm_missing(self, pkgs, dtype): for prog in pkgs: try: self.run(["rpm", "-q", prog], check=3DTrue) except subprocess.CalledProcessError: - self.add_package(prog, dtype) + self.deps.add_package(prog, dtype) =20 def check_pacman_missing(self, pkgs, dtype): for prog in pkgs: try: self.run(["pacman", "-Q", prog], check=3DTrue) except subprocess.CalledProcessError: - self.add_package(prog, dtype) + self.deps.add_package(prog, dtype) =20 def check_missing_tex(self, is_optional=3DFalse): if is_optional: - dtype =3D DepType.PDF_OPTIONAL + dtype =3D DepManager.PDF_OPTIONAL else: - dtype =3D DepType.PDF_MANDATORY + dtype =3D DepManager.PDF_MANDATORY =20 kpsewhich =3D self.which("kpsewhich") for prog, package in self.texlive.items(): =20 # If kpsewhich is not there, just add it to deps if not kpsewhich: - self.add_package(package, dtype) + self.deps.add_package(package, dtype) continue =20 # Check if the package is needed @@ -396,11 +419,11 @@ class SphinxDependencyChecker: =20 # Didn't find. Add it if not result.stdout.strip(): - self.add_package(package, dtype) + self.deps.add_package(package, dtype) =20 except subprocess.CalledProcessError: # kpsewhich returned an error. Add it, just in case - self.add_package(package, dtype) + self.deps.add_package(package, dtype) =20 def get_sphinx_fname(self): if "SPHINXBUILD" in os.environ: @@ -478,6 +501,17 @@ class SphinxDependencyChecker: return f.read().strip() return "" =20 + def check_missing(self, progs): + self.install +=3D self.deps.check_missing(progs) + if self.verbose_warn_install: + self.deps.warn_install() + + if not self.deps.need and not self.deps.optional: + return False + + return True + + # # Distro-specific hints methods # @@ -511,13 +545,11 @@ class SphinxDependencyChecker: } =20 for package, files in pdf_pkgs.items(): - self.check_missing_file(files, package, DepType.PDF_MANDAT= ORY) + self.check_missing_file(files, package, DepManager.PDF_MAN= DATORY) =20 - self.check_program("dvipng", DepType.PDF_MANDATORY) + self.check_program("dvipng", DepManager.PDF_MANDATORY) =20 - self.check_missing(progs) - - if not self.need and not self.optional: + if self.check_missing(progs): return =20 if self.verbose_warn_install: @@ -575,7 +607,7 @@ class SphinxDependencyChecker: # RHEL 8 uses Python 3.6, which is not compatible with # the build system anymore. Suggest Python 3.11 if rel =3D=3D 8: - self.add_package("python39", DepType.SYSTEM_MANDATORY) + self.deps.add_package("python39", DepManager.SYSTEM_MANDAT= ORY) self.recommend_python =3D True =20 if self.first_hint: @@ -597,22 +629,18 @@ class SphinxDependencyChecker: "/usr/share/fonts/google-noto-sans-cjk-fonts/NotoSansCJK-R= egular.ttc", ] =20 - self.check_missing_file(pdf_pkgs, noto_sans_redhat, DepType.PD= F_MANDATORY) + self.check_missing_file(pdf_pkgs, noto_sans_redhat, DepManager= .PDF_MANDATORY) =20 - self.check_rpm_missing(fedora_tex_pkgs, DepType.PDF_MANDATORY) + self.check_rpm_missing(fedora_tex_pkgs, DepManager.PDF_MANDATO= RY) =20 - self.check_missing_tex(DepType.PDF_MANDATORY) + self.check_missing_tex(DepManager.PDF_MANDATORY) =20 # There's no texlive-ctex on RHEL 8 repositories. This will # likely affect CJK pdf build only. if not fedora and rel =3D=3D 8: - if "texlive-ctex" in self.missing: - del self.missing["texlive-ctex"] + self.deps.del_package("texlive-ctex") =20 - - self.check_missing(progs) - - if not self.need and not self.optional: + if self.check_missing(progs): return =20 if self.verbose_warn_install: @@ -659,7 +687,7 @@ class SphinxDependencyChecker: if rel =3D=3D 15: if not self.which(self.python_cmd): self.recommend_python =3D True - self.add_package(self.python_cmd, DepType.SYSTEM_MANDA= TORY) + self.deps.add_package(self.python_cmd, DepManager.SYST= EM_MANDATORY) =20 progs.update({ "python-sphinx": "python311-Sphinx", @@ -681,12 +709,11 @@ class SphinxDependencyChecker: # "Noto Sans CJK SC" on openSUSE =20 if self.pdf: - self.check_rpm_missing(suse_tex_pkgs, DepType.PDF_MANDATORY) + self.check_rpm_missing(suse_tex_pkgs, DepManager.PDF_MANDATORY) if self.pdf: self.check_missing_tex() - self.check_missing(progs) =20 - if not self.need and not self.optional: + if self.check_missing(progs): return =20 if self.verbose_warn_install: @@ -730,13 +757,12 @@ class SphinxDependencyChecker: "/usr/share/fonts/TTF/NotoSans-Regular.ttf", ] =20 - self.check_missing_file(pdf_pkgs, noto_sans, DepType.PDF_MANDA= TORY) - self.check_rpm_missing(tex_pkgs, DepType.PDF_MANDATORY) + self.check_missing_file(pdf_pkgs, noto_sans, DepManager.PDF_MA= NDATORY) + self.check_rpm_missing(tex_pkgs, DepManager.PDF_MANDATORY) =20 - self.check_missing(progs) - - if not self.need and not self.optional: + if self.check_missing(progs): return + if self.verbose_warn_install: print("You should run:") print(f"\n\tsudo {packager_cmd} {self.install}") @@ -759,7 +785,7 @@ class SphinxDependencyChecker: ] =20 if self.pdf: - self.check_pacman_missing(archlinux_tex_pkgs, DepType.PDF_MAND= ATORY) + self.check_pacman_missing(archlinux_tex_pkgs, DepManager.PDF_M= ANDATORY) =20 self.check_missing_file( ["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], @@ -767,10 +793,9 @@ class SphinxDependencyChecker: 2, ) =20 - self.check_missing(progs) - - if not self.need and not self.optional: + if self.check_missing(progs): return + if self.verbose_warn_install: print("You should run:") print(f"\n\tsudo pacman -S {self.install}") @@ -797,11 +822,9 @@ class SphinxDependencyChecker: ], } for package, files in pdf_pkgs.items(): - self.check_missing_file(files, package, DepType.PDF_MANDAT= ORY) + self.check_missing_file(files, package, DepManager.PDF_MAN= DATORY) =20 - self.check_missing(progs) - - if not self.need and not self.optional: + if self.check_missing(progs): return =20 if self.verbose_warn_install: @@ -1039,16 +1062,18 @@ class SphinxDependencyChecker: =20 print("\n2) As a package with:") =20 - old_need =3D self.need - old_optional =3D self.optional - self.missing =3D {} + old_need =3D self.deps.need + old_optional =3D self.deps.optional + self.pdf =3D False self.optional =3D 0 self.install =3D "" old_verbose =3D self.verbose_warn_install self.verbose_warn_install =3D 0 =20 - self.add_package("python-sphinx", DepType.PYTHON_MANDATORY) + self.deps.clear_deps() + + self.deps.add_package("python-sphinx", DepManager.PYTHON_MANDATORY) =20 self.check_distros() =20 @@ -1111,7 +1136,7 @@ class SphinxDependencyChecker: print("\n") else: if self.need_sphinx: - self.need +=3D 1 + self.deps.need +=3D 1 =20 # Suggest newer versions if current ones are too old if self.latest_avail_ver and self.latest_avail_ver >=3D self.min_v= ersion: @@ -1190,20 +1215,20 @@ class SphinxDependencyChecker: self.check_python_module("ensurepip") =20 # Check for needed programs/tools - self.check_perl_module("Pod::Usage", DepType.SYSTEM_MANDATORY) + self.check_perl_module("Pod::Usage", DepManager.SYSTEM_MANDATORY) =20 - self.check_program("make", DepType.SYSTEM_MANDATORY) - self.check_program("gcc", DepType.SYSTEM_MANDATORY) + self.check_program("make", DepManager.SYSTEM_MANDATORY) + self.check_program("gcc", DepManager.SYSTEM_MANDATORY) =20 - self.check_program("dot", DepType.SYSTEM_OPTIONAL) - self.check_program("convert", DepType.SYSTEM_OPTIONAL) + self.check_program("dot", DepManager.SYSTEM_OPTIONAL) + self.check_program("convert", DepManager.SYSTEM_OPTIONAL) =20 self.check_python_module("yaml") =20 if self.pdf: - self.check_program("xelatex", DepType.PDF_MANDATORY) - self.check_program("rsvg-convert", DepType.PDF_MANDATORY) - self.check_program("latexmk", DepType.PDF_MANDATORY) + self.check_program("xelatex", DepManager.PDF_MANDATORY) + self.check_program("rsvg-convert", DepManager.PDF_MANDATORY) + self.check_program("latexmk", DepManager.PDF_MANDATORY) =20 # Do distro-specific checks and output distro-install commands self.check_distros() --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E97C2F83AB; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=aX8/W6ps6suCAFyzSOnTGGKwHSImcGI3ZDtfD4Z6cA21k1gmkNYPwAaPshTF0NpvZu6mL+//WchI/22G8Yyzi5qTll5A6c7hKKshxh1t8BDkESVMVWeR9phlQKS9x4qsJXVRqTs/W/0D3DJ8hu7lvQXRsjtDphyV43dxA/UQ+NY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=ItIkJyr4HT0xtooM1nUIr4FJ0PKDwnkSm1jezVW3R2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sM7Zw+bSxkv21tTPFBdONOb+yDmS3BHclXljrz8z8ctyhLHE5fWAFglslNFkCEr000rTulmM1ZJ/Zm8nWGARHFL514NB7pWinL/CGytfR743/gM6YiYASsxCMsrpG/aHn/BNlMvxMClotH8KzQFp6Ca0kRelXRe0o+NFr7UQ//8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oJvkgrZk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oJvkgrZk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F40B4C4AF1C; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=ItIkJyr4HT0xtooM1nUIr4FJ0PKDwnkSm1jezVW3R2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJvkgrZkKkXGQJEYFtLP2iaNJg4BLn1zHUONvIY2ZXcext028TZGoOstV3hCweafR XUc/LuJTlrWAYVrL0ub1vli8gnK8cUmIuvixaF0Ks5gLALT0QZwRNLJ/2afFcnyzMa 4Yo9GM7RRD80/zrfHt+VNg1XDEz27xyurHFpCWsgCWNEn9R49PdOUONPJfO9Vho+90 x0Hnt/reEa7P4UMOOOWj8Lc9wAx3J50KvlSYQOZZ+XzT/v3IDqfPNKL1Tk6qVYNcQx 7KIO61BENCltobikUe7tKTw0TcgYEedFdKVV1OeUBzRKUg67pReIquMVzjp6CaP0fm ZugIgCuyOACJA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kWw-3ZWr; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 27/39] scripts: sphinx-pre-install: move ancillary checkers to a separate class Date: Tue, 12 Aug 2025 17:52:44 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The code there are just a bunch of static functions that are used by the main class. group them altogether to better organize the code. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 160 +++++++++++++++++----------------- 1 file changed, 81 insertions(+), 79 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 47dce1fcddfb..b00e50028f4d 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -150,85 +150,11 @@ class DepManager: if output_msg: print(f"\n{output_msg}\n") =20 -class SphinxDependencyChecker: - # List of required texlive packages on Fedora and OpenSuse - texlive =3D { - "amsfonts.sty": "texlive-amsfonts", - "amsmath.sty": "texlive-amsmath", - "amssymb.sty": "texlive-amsfonts", - "amsthm.sty": "texlive-amscls", - "anyfontsize.sty": "texlive-anyfontsize", - "atbegshi.sty": "texlive-oberdiek", - "bm.sty": "texlive-tools", - "capt-of.sty": "texlive-capt-of", - "cmap.sty": "texlive-cmap", - "ctexhook.sty": "texlive-ctex", - "ecrm1000.tfm": "texlive-ec", - "eqparbox.sty": "texlive-eqparbox", - "eu1enc.def": "texlive-euenc", - "fancybox.sty": "texlive-fancybox", - "fancyvrb.sty": "texlive-fancyvrb", - "float.sty": "texlive-float", - "fncychap.sty": "texlive-fncychap", - "footnote.sty": "texlive-mdwtools", - "framed.sty": "texlive-framed", - "luatex85.sty": "texlive-luatex85", - "multirow.sty": "texlive-multirow", - "needspace.sty": "texlive-needspace", - "palatino.sty": "texlive-psnfss", - "parskip.sty": "texlive-parskip", - "polyglossia.sty": "texlive-polyglossia", - "tabulary.sty": "texlive-tabulary", - "threeparttable.sty": "texlive-threeparttable", - "titlesec.sty": "texlive-titlesec", - "ucs.sty": "texlive-ucs", - "upquote.sty": "texlive-upquote", - "wrapfig.sty": "texlive-wrapfig", - } - - def __init__(self, args): - self.pdf =3D args.pdf - self.virtualenv =3D args.virtualenv - self.version_check =3D args.version_check - - self.deps =3D DepManager(self.pdf) - - self.need_symlink =3D 0 - self.need_sphinx =3D 0 - self.need_pip =3D 0 - self.rec_sphinx_upgrade =3D 0 - self.verbose_warn_install =3D 1 - - self.system_release =3D "" - self.install =3D "" - self.virtenv_dir =3D "" - self.python_cmd =3D "" - self.activate_cmd =3D "" - - # Some distros may not have a Sphinx shipped package compatible wi= th - # our minimal requirements - self.package_supported =3D True - - # Recommend a new python version - self.recommend_python =3D None - - # Certain hints are meant to be shown only once - self.first_hint =3D True - - self.min_version =3D (0, 0, 0) - self.cur_version =3D (0, 0, 0) - self.latest_avail_ver =3D (0, 0, 0) - self.venv_ver =3D (0, 0, 0) - - prefix =3D os.environ.get("srctree", ".") + "/" - - self.conf =3D prefix + "Documentation/conf.py" - self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" - self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] - - # - # Ancillary methods that don't depend on self - # +class AncillaryCheckers: + """ + Ancillary methods that checks for missing dependencies for different + types of types, like binaries, python modules, rpm deps, etc. + """ =20 @staticmethod def which(prog): @@ -335,6 +261,82 @@ class SphinxDependencyChecker: =20 return subprocess.run(*args, **kwargs) =20 +class SphinxDependencyChecker(AncillaryCheckers): + # List of required texlive packages on Fedora and OpenSuse + texlive =3D { + "amsfonts.sty": "texlive-amsfonts", + "amsmath.sty": "texlive-amsmath", + "amssymb.sty": "texlive-amsfonts", + "amsthm.sty": "texlive-amscls", + "anyfontsize.sty": "texlive-anyfontsize", + "atbegshi.sty": "texlive-oberdiek", + "bm.sty": "texlive-tools", + "capt-of.sty": "texlive-capt-of", + "cmap.sty": "texlive-cmap", + "ctexhook.sty": "texlive-ctex", + "ecrm1000.tfm": "texlive-ec", + "eqparbox.sty": "texlive-eqparbox", + "eu1enc.def": "texlive-euenc", + "fancybox.sty": "texlive-fancybox", + "fancyvrb.sty": "texlive-fancyvrb", + "float.sty": "texlive-float", + "fncychap.sty": "texlive-fncychap", + "footnote.sty": "texlive-mdwtools", + "framed.sty": "texlive-framed", + "luatex85.sty": "texlive-luatex85", + "multirow.sty": "texlive-multirow", + "needspace.sty": "texlive-needspace", + "palatino.sty": "texlive-psnfss", + "parskip.sty": "texlive-parskip", + "polyglossia.sty": "texlive-polyglossia", + "tabulary.sty": "texlive-tabulary", + "threeparttable.sty": "texlive-threeparttable", + "titlesec.sty": "texlive-titlesec", + "ucs.sty": "texlive-ucs", + "upquote.sty": "texlive-upquote", + "wrapfig.sty": "texlive-wrapfig", + } + + def __init__(self, args): + self.pdf =3D args.pdf + self.virtualenv =3D args.virtualenv + self.version_check =3D args.version_check + + self.deps =3D DepManager(self.pdf) + + self.need_symlink =3D 0 + self.need_sphinx =3D 0 + self.need_pip =3D 0 + self.rec_sphinx_upgrade =3D 0 + self.verbose_warn_install =3D 1 + + self.system_release =3D "" + self.install =3D "" + self.virtenv_dir =3D "" + self.python_cmd =3D "" + self.activate_cmd =3D "" + + # Some distros may not have a Sphinx shipped package compatible wi= th + # our minimal requirements + self.package_supported =3D True + + # Recommend a new python version + self.recommend_python =3D None + + # Certain hints are meant to be shown only once + self.first_hint =3D True + + self.min_version =3D (0, 0, 0) + self.cur_version =3D (0, 0, 0) + self.latest_avail_ver =3D (0, 0, 0) + self.venv_ver =3D (0, 0, 0) + + prefix =3D os.environ.get("srctree", ".") + "/" + + self.conf =3D prefix + "Documentation/conf.py" + self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" + self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] + # # Methods to check if a feature exists # --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A12EC2F83BC; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=Dpbb3IzMM6pcUc9fMgyHkqQ1V67vJaYd5XeVkfj59ocCESrVqefEIzZSXH1JK1bBwXgurM8WTpOq8lawf7VRf43ov+emTdoNm2/bKOkb4pzirgrKHCCpvXb+BuIxozeQBYgEvON3fIHFMoN0VMtC9OqUM0xJPeYPjYakDfC1mx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=2YsXAMd/pCiQ6uIzzxaRELl35dvP/BI9lWiGv4U9Fk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CahX2k8r7g0Q62RbVMlGBFqHBSoih/qpjLWOkaUHq5FMv5UE5dRBVEJjesQ/E9tUIJJb/k0zAuzr4Q+YRZXEfgOYBR0gwmjOZdRIN+fBgdu61ycoG7IgH9tyo1g3OTyQ7ZLxXb8YWwjOFER5W7QTxeaVvnFlKWU7CJnb8xq1O3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7zLsrAS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I7zLsrAS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E43D8C19421; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=2YsXAMd/pCiQ6uIzzxaRELl35dvP/BI9lWiGv4U9Fk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I7zLsrASYMz8iMRtwIQuFxK2wMbcAz0MyUbU0kvJOj/v9BdYMykafy1H7JV1CfBsf CogXXNjilQNsiL0HvKywdQtnJqhs6jowIGDBt8Uaa7bzWLZG4C8ghuFN+EfqmTVlvC +xovnQ84TI9AgETr8yVP1nr7Yj3wygSE45sTOxFrGKmYnDpq+KnvPgffV5FMDkVlRH mceZ+UppO4JRvrtNTsSj4S1ZelRiHhshCAo4DbwkUucmbcX6/FIy+Vg3mys0Qttahz yiifo26yCwXKL0Vwe7ewB5gn2eZWCzVfnxtgllD9h1Ts0HZzkWejWO3iUEoFBaunPt psE5SZq9AJI7g== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kX0-3hv5; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 28/39] scripts: sphinx-pre-install: add more generic checkers on a class Date: Tue, 12 Aug 2025 17:52:45 +0200 Message-ID: <11a252fe816bd7c85583d26ade0666eb2b481bf0.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Better organize the code by moving the more generic methods to MissingCheckers. Such class contain only binary and package dependent missing checkers, but no distro-specific data or code. All distro-specific data/code remains at SphinxDependencyChecker class. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 142 ++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 66 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index b00e50028f4d..9127487bd4d7 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -150,7 +150,7 @@ class DepManager: if output_msg: print(f"\n{output_msg}\n") =20 -class AncillaryCheckers: +class AncillaryMethods: """ Ancillary methods that checks for missing dependencies for different types of types, like binaries, python modules, rpm deps, etc. @@ -261,81 +261,24 @@ class AncillaryCheckers: =20 return subprocess.run(*args, **kwargs) =20 -class SphinxDependencyChecker(AncillaryCheckers): - # List of required texlive packages on Fedora and OpenSuse - texlive =3D { - "amsfonts.sty": "texlive-amsfonts", - "amsmath.sty": "texlive-amsmath", - "amssymb.sty": "texlive-amsfonts", - "amsthm.sty": "texlive-amscls", - "anyfontsize.sty": "texlive-anyfontsize", - "atbegshi.sty": "texlive-oberdiek", - "bm.sty": "texlive-tools", - "capt-of.sty": "texlive-capt-of", - "cmap.sty": "texlive-cmap", - "ctexhook.sty": "texlive-ctex", - "ecrm1000.tfm": "texlive-ec", - "eqparbox.sty": "texlive-eqparbox", - "eu1enc.def": "texlive-euenc", - "fancybox.sty": "texlive-fancybox", - "fancyvrb.sty": "texlive-fancyvrb", - "float.sty": "texlive-float", - "fncychap.sty": "texlive-fncychap", - "footnote.sty": "texlive-mdwtools", - "framed.sty": "texlive-framed", - "luatex85.sty": "texlive-luatex85", - "multirow.sty": "texlive-multirow", - "needspace.sty": "texlive-needspace", - "palatino.sty": "texlive-psnfss", - "parskip.sty": "texlive-parskip", - "polyglossia.sty": "texlive-polyglossia", - "tabulary.sty": "texlive-tabulary", - "threeparttable.sty": "texlive-threeparttable", - "titlesec.sty": "texlive-titlesec", - "ucs.sty": "texlive-ucs", - "upquote.sty": "texlive-upquote", - "wrapfig.sty": "texlive-wrapfig", - } +class MissingCheckers(AncillaryMethods): =20 - def __init__(self, args): + def __init__(self, args, texlive): self.pdf =3D args.pdf self.virtualenv =3D args.virtualenv self.version_check =3D args.version_check + self.texlive =3D texlive =20 self.deps =3D DepManager(self.pdf) =20 self.need_symlink =3D 0 self.need_sphinx =3D 0 - self.need_pip =3D 0 - self.rec_sphinx_upgrade =3D 0 + self.verbose_warn_install =3D 1 =20 - self.system_release =3D "" - self.install =3D "" self.virtenv_dir =3D "" - self.python_cmd =3D "" - self.activate_cmd =3D "" =20 - # Some distros may not have a Sphinx shipped package compatible wi= th - # our minimal requirements - self.package_supported =3D True - - # Recommend a new python version - self.recommend_python =3D None - - # Certain hints are meant to be shown only once - self.first_hint =3D True - - self.min_version =3D (0, 0, 0) - self.cur_version =3D (0, 0, 0) - self.latest_avail_ver =3D (0, 0, 0) - self.venv_ver =3D (0, 0, 0) - - prefix =3D os.environ.get("srctree", ".") + "/" - - self.conf =3D prefix + "Documentation/conf.py" - self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" - self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] + self.install =3D "" =20 # # Methods to check if a feature exists @@ -460,9 +403,9 @@ class SphinxDependencyChecker(AncillaryCheckers): if match: return parse_version(match.group(1)) =20 - def check_sphinx(self): + def check_sphinx(self, conf): try: - with open(self.conf, "r", encoding=3D"utf-8") as f: + with open(conf, "r", encoding=3D"utf-8") as f: for line in f: match =3D re.match(r"^\s*needs_sphinx\s*=3D\s*[\'\"]([= \d\.]+)[\'\"]", line) if match: @@ -513,6 +456,73 @@ class SphinxDependencyChecker(AncillaryCheckers): =20 return True =20 +class SphinxDependencyChecker(MissingCheckers): + + def __init__(self, args): + # List of required texlive packages on Fedora and OpenSuse + texlive =3D { + "amsfonts.sty": "texlive-amsfonts", + "amsmath.sty": "texlive-amsmath", + "amssymb.sty": "texlive-amsfonts", + "amsthm.sty": "texlive-amscls", + "anyfontsize.sty": "texlive-anyfontsize", + "atbegshi.sty": "texlive-oberdiek", + "bm.sty": "texlive-tools", + "capt-of.sty": "texlive-capt-of", + "cmap.sty": "texlive-cmap", + "ctexhook.sty": "texlive-ctex", + "ecrm1000.tfm": "texlive-ec", + "eqparbox.sty": "texlive-eqparbox", + "eu1enc.def": "texlive-euenc", + "fancybox.sty": "texlive-fancybox", + "fancyvrb.sty": "texlive-fancyvrb", + "float.sty": "texlive-float", + "fncychap.sty": "texlive-fncychap", + "footnote.sty": "texlive-mdwtools", + "framed.sty": "texlive-framed", + "luatex85.sty": "texlive-luatex85", + "multirow.sty": "texlive-multirow", + "needspace.sty": "texlive-needspace", + "palatino.sty": "texlive-psnfss", + "parskip.sty": "texlive-parskip", + "polyglossia.sty": "texlive-polyglossia", + "tabulary.sty": "texlive-tabulary", + "threeparttable.sty": "texlive-threeparttable", + "titlesec.sty": "texlive-titlesec", + "ucs.sty": "texlive-ucs", + "upquote.sty": "texlive-upquote", + "wrapfig.sty": "texlive-wrapfig", + } + + super().__init__(args, texlive) + + self.need_pip =3D 0 + self.rec_sphinx_upgrade =3D 0 + + self.system_release =3D "" + self.python_cmd =3D "" + self.activate_cmd =3D "" + + # Some distros may not have a Sphinx shipped package compatible wi= th + # our minimal requirements + self.package_supported =3D True + + # Recommend a new python version + self.recommend_python =3D None + + # Certain hints are meant to be shown only once + self.first_hint =3D True + + self.min_version =3D (0, 0, 0) + self.cur_version =3D (0, 0, 0) + self.latest_avail_ver =3D (0, 0, 0) + self.venv_ver =3D (0, 0, 0) + + prefix =3D os.environ.get("srctree", ".") + "/" + + self.conf =3D prefix + "Documentation/conf.py" + self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" + self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] =20 # # Distro-specific hints methods @@ -1187,7 +1197,7 @@ class SphinxDependencyChecker(AncillaryCheckers): self.python_cmd =3D sys.executable =20 # Check if Sphinx is already accessible from current environment - self.check_sphinx() + self.check_sphinx(self.conf) =20 if self.system_release: print(f"Detected OS: {self.system_release}.") --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 971D22F83AF; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=ZS8hkB2ab0SLyrHW9HFnFsu3klJ30qOOCkpDZ5b0n7/En6Fo11u+y+4j/+3bhDRh2+EU0Q931tUZzkHH/VugabDkzoLEwE9GwOjUu2BmKm9hT5VKj9ZPMhcUM6NWm5aXflSNO3ZoHkEgE2RzRKXR7TX36wa2i9+qo6+XlAPxLlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=FbaXRUc/2LhlVOjM23W2WjLiwG7E6R+Z0hI5EFxslxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eXG7di6ortikFRhUqiMjxDmg8RlX4+icT5U0dj4L1rT9AVmLQA4pOUtp3mCyY8A3hSSjzs+gaGl0eKl8exYS6uqDvndjER/rBShcF07OxhsV0L/UFGLSA9B9Oz3qS8q3j9r+F6mqxV4XjzbvtGEgXZ45Z2AL5DUuH9KlGBcXCNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ut14kbE/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ut14kbE/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F15A6C4AF18; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=FbaXRUc/2LhlVOjM23W2WjLiwG7E6R+Z0hI5EFxslxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ut14kbE/HQDAJ09VzDqQ6b7H8eSyNHa8Di/LEjowgNl57kFBjQx/xgBCnGX6aIiK/ HiYeE/isG0yA5YTMnSpQlv7Sph/l/TNFMKp4SzudH9yjr4F2KBAKlWjHgTs0XZPqkr ZbDfsC0vSsCdvmipAkclB/1nZyZ+Z3F0r/ZRM6PiVCbXbxi7OBHFmsCK3HZCEmPMvi 2ucFNiQmU3FONNAcOkoLp7BHU9p5QRdoDnd1XvdvhMEySm9fnGQtP6YV1GCm11SEjI tvBOI8Nso2NS70Ob43pWMovxwZlg6C+p17XGgV0rmZgVdDrwBrctd4EDD63VfCAxBh 5CEqN3/lTx/Aw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kX4-3p8W; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 29/39] scripts: sphinx-pre-install: move get_system_release() Date: Tue, 12 Aug 2025 17:52:46 +0200 Message-ID: <4b42a85bbb6575bb34a58cf66019038c4afa1d5b.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The code at get_system_release() is actually a helper function, independent from the actual Sphinx verification checker. Move it to MissingCheckers class, where other checkers are present. With that, the entire distro-specific handler logic, with all its complexity is confined at SphinxDependencyChecker class. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 115 +++++++++++++++++----------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 9127487bd4d7..593982f350b3 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -456,6 +456,64 @@ class MissingCheckers(AncillaryMethods): =20 return True =20 + def get_system_release(self): + """ + Determine the system type. There's no unique way that would work + with all distros with a minimal package install. So, several + methods are used here. + + By default, it will use lsb_release function. If not available, it= will + fail back to reading the known different places where the distro n= ame + is stored. + + Several modern distros now have /etc/os-release, which usually have + a decent coverage. + """ + + system_release =3D "" + + if self.which("lsb_release"): + result =3D self.run(["lsb_release", "-d"], capture_output=3DTr= ue, text=3DTrue) + system_release =3D result.stdout.replace("Description:", "").s= trip() + + release_files =3D [ + "/etc/system-release", + "/etc/redhat-release", + "/etc/lsb-release", + "/etc/gentoo-release", + ] + + if not system_release: + for f in release_files: + system_release =3D self.catcheck(f) + if system_release: + break + + # This seems more common than LSB these days + if not system_release: + os_var =3D {} + try: + with open("/etc/os-release", "r", encoding=3D"utf-8") as f: + for line in f: + match =3D re.match(r"^([\w\d\_]+)=3D\"?([^\"]*)\"?= \n", line) + if match: + os_var[match.group(1)] =3D match.group(2) + + system_release =3D os_var.get("NAME", "") + if "VERSION_ID" in os_var: + system_release +=3D " " + os_var["VERSION_ID"] + elif "VERSION" in os_var: + system_release +=3D " " + os_var["VERSION"] + except IOError: + pass + + if not system_release: + system_release =3D self.catcheck("/etc/issue") + + system_release =3D system_release.strip() + + return system_release + class SphinxDependencyChecker(MissingCheckers): =20 def __init__(self, args): @@ -499,7 +557,7 @@ class SphinxDependencyChecker(MissingCheckers): self.need_pip =3D 0 self.rec_sphinx_upgrade =3D 0 =20 - self.system_release =3D "" + self.system_release =3D self.get_system_release() self.python_cmd =3D "" self.activate_cmd =3D "" =20 @@ -1193,7 +1251,6 @@ class SphinxDependencyChecker(MissingCheckers): "\thttps://github.com/sphinx-doc/sphinx/pull/8313") =20 def check_needs(self): - self.get_system_release() self.python_cmd =3D sys.executable =20 # Check if Sphinx is already accessible from current environment @@ -1270,60 +1327,6 @@ class SphinxDependencyChecker(MissingCheckers): =20 print("Needed package dependencies are met.") =20 - def get_system_release(self): - """ - Determine the system type. There's no unique way that would work - with all distros with a minimal package install. So, several - methods are used here. - - By default, it will use lsb_release function. If not available, it= will - fail back to reading the known different places where the distro n= ame - is stored. - - Several modern distros now have /etc/os-release, which usually have - a decent coverage. - """ - - if self.which("lsb_release"): - result =3D self.run(["lsb_release", "-d"], capture_output=3DTr= ue, text=3DTrue) - self.system_release =3D result.stdout.replace("Description:", = "").strip() - - release_files =3D [ - "/etc/system-release", - "/etc/redhat-release", - "/etc/lsb-release", - "/etc/gentoo-release", - ] - - if not self.system_release: - for f in release_files: - self.system_release =3D self.catcheck(f) - if self.system_release: - break - - # This seems more common than LSB these days - if not self.system_release: - os_var =3D {} - try: - with open("/etc/os-release", "r", encoding=3D"utf-8") as f: - for line in f: - match =3D re.match(r"^([\w\d\_]+)=3D\"?([^\"]*)\"?= \n", line) - if match: - os_var[match.group(1)] =3D match.group(2) - - self.system_release =3D os_var.get("NAME", "") - if "VERSION_ID" in os_var: - self.system_release +=3D " " + os_var["VERSION_ID"] - elif "VERSION" in os_var: - self.system_release +=3D " " + os_var["VERSION"] - except IOError: - pass - - if not self.system_release: - self.system_release =3D self.catcheck("/etc/issue") - - self.system_release =3D self.system_release.strip() - DESCRIPTION =3D """ Process some flags related to Sphinx installation and documentation build. """ --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0BC32F83DC; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=tWqey6zS+p4QW6lvwTNY/OVAp40PFZ52MhOSkOkdAYQUfNqUTdaGqhbhmxULzSAzaiYEOu4VhP5fwrbxvCrn4k3ORrj52Zqi8598lHFHrgP9TbGuxNTYNgXX0/22+Pp8D1FI8MJcnM8vnSzy4XRW+c0GR/9jQ0ColLr1yi5tR9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=uqIRNdCp3Pn2ZqFb+15hEn/Z/fdxxnN1r1BLsk95MfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yz4EAWBeyOU76HSCqIjsKsbVu4ntTYqJSScB9K+8PiM6AMWI6meCPnOQVaYzqHEx80b2Epa31rh1xb6Kss9Xhem2H2eODLNcdMjdTbRplEaB/7sdhJ77Tq+h23wq0ae60oQcM4ioa06Zs8r7Tu/CFui/OEYa/+82gmOYqX/GD0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qu/Kta/P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qu/Kta/P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0797C4AF13; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=uqIRNdCp3Pn2ZqFb+15hEn/Z/fdxxnN1r1BLsk95MfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qu/Kta/PCrcmm37XJCSinv44U/dkHkHQ1Y86eh9tNHGhc57rzVHRQdap4GCh71XQl kwitLSnETOs3re5i6kFhUt5F4XD5608TMyrLGZiNpNldyD8rGtESGv915Lxqd1LK+o Xa7B0UccthRhhp0grRXfTloO+PFP3XCjVe3U/fz+wPHBp9IfMXpsLHgq8J+BBq1zbq V+ekrh01Nl3Bu2A78M/eenhewRupXL6L0TH5Ue2eqojR2tLQnPtE1niyCfXPigPG7j azZccXwbxq7yReE6jwufnirIQxazgC0egGNKJrvcyRC/24j/xL9v2sjyky3+0mSpkX OyfAvijDGaVaA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kX8-3wyT; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 30/39] scripts: sphinx-pre-install: add documentation for the ancillary classes. Date: Tue, 12 Aug 2025 17:52:47 +0200 Message-ID: <7421112b14edf5c21cc4cf0f2ee320fcaf874b40.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" While here, rename a parameter to have its usage better documented. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 162 +++++++++++++++++++++++++++++----- 1 file changed, 140 insertions(+), 22 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 593982f350b3..1dc3f19804ab 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -33,35 +33,62 @@ MIN_PYTHON_VERSION =3D parse_version("3.7") =20 =20 class DepManager: + """ + Manage package dependencies. There are three types of dependencies: =20 - # Internal types of dependencies. + - System: dependencies required for docs build; + - Python: python dependencies for a native distro Sphinx install; + - PDF: dependencies needed by PDF builds. + + Each dependency can be mandatory or optional. Not installing an option= al + dependency won't break the build, but will cause degradation at the + docs output. + """ + + # Internal types of dependencies. Don't use them outside DepManager cl= ass. _SYS_TYPE =3D 0 _PHY_TYPE =3D 1 _PDF_TYPE =3D 2 =20 - # Let's define keys as a tuple with the type and mandatory/optional. - # This way, checking for optional or type is easy. + # Dependencies visible outside the class. + # The keys are tuple with: (type, is_mandatory flag). + # + # Currently we're not using all optional dep types. Yet, we'll keep all + # possible combinations here. They're not many, and that makes easier + # if later needed and for the name() method below =20 SYSTEM_MANDATORY =3D (_SYS_TYPE, True) PYTHON_MANDATORY =3D (_PHY_TYPE, True) PDF_MANDATORY =3D (_PDF_TYPE, True) =20 - # Currently we're not using all optional types, but let's keep all - # combinations here, as we may end needing them in the future. Also, - # it allows a name() function that handles all possibilities. SYSTEM_OPTIONAL =3D (_SYS_TYPE, False) PYTHON_OPTIONAL =3D (_PHY_TYPE, False) PDF_OPTIONAL =3D (_PDF_TYPE, True) =20 def __init__(self, pdf): + """ + Initialize internal vars: + + - missing: missing dependencies list, containing a distro-independ= ent + name for a missing dependency and its type. + - missing_pkg: ancillary dict containing missing dependencies in + distro namespace, organized by type. + - need: total number of needed dependencies. Never cleaned. + - optional: total number of optional dependencies. Never cleaned. + - pdf: PDF support is enabled? + """ self.missing =3D {} - self.run =3D {} + self.missing_pkg =3D {} self.need =3D 0 self.optional =3D 0 self.pdf =3D pdf =20 @staticmethod def name(dtype): + """ + Ancillary routine to output a warn/error message reporting + missing dependencies. + """ if dtype[0] =3D=3D DepManager._SYS_TYPE: msg =3D "build" elif dtype[0] =3D=3D DepManager._PHY_TYPE: @@ -76,16 +103,22 @@ class DepManager: =20 @staticmethod def is_optional(dtype): + """Ancillary routine to report if a dependency is optional""" return not dtype[1] =20 @staticmethod def is_pdf(dtype): + """Ancillary routine to report if a dependency is for PDF generati= on""" if (dtype[0] =3D=3D DepManager._PDF_TYPE): return True =20 return False =20 def add_package(self, package, dtype): + """ + Add a package at the self.missing() dictionary. + Doesn't update missing_pkg. + """ is_optional =3D DepManager.is_optional(dtype) self.missing[package] =3D dtype if is_optional: @@ -94,6 +127,10 @@ class DepManager: self.need +=3D 1 =20 def del_package(self, package): + """ + Remove a package at the self.missing() dictionary. + Doesn't update missing_pkg. + """ if package in self.missing: del self.missing[package] =20 @@ -104,13 +141,22 @@ class DepManager: This is an ackward way to have a separate section to recommend a package after system main dependencies. =20 - TODO: rework the logic to prevent needing it + TODO: rework the logic to prevent needing it. """ =20 self.missing =3D {} + self.missing_pkg =3D {} =20 def check_missing(self, progs): - self.run =3D {} + """ + Update self.missing_pkg, using progs dict to convert from the + agnostic package name to distro-specific one. + + Returns an string with the packages to be installed, sorted and + with eventual duplicates removed. + """ + + self.missing_pkg =3D {} =20 for prog, dtype in sorted(self.missing.items()): # At least on some LTS distros like CentOS 7, texlive doesn't @@ -123,23 +169,26 @@ class DepManager: self.optional -=3D 1 continue =20 - if not dtype in self.run: - self.run[dtype] =3D [] + if not dtype in self.missing_pkg: + self.missing_pkg[dtype] =3D [] =20 - self.run[dtype].append(progs.get(prog, prog)) + self.missing_pkg[dtype].append(progs.get(prog, prog)) =20 install =3D [] - for dtype in self.run.keys(): - install +=3D self.run[dtype] + for dtype in self.missing_pkg.keys(): + install +=3D self.missing_pkg[dtype] =20 return " ".join(sorted(set(install))) =20 def warn_install(self): + """ + Emit warnings/errors related to missing packages. + """ =20 output_msg =3D "" =20 - for dtype in sorted(self.run.keys()): - progs =3D " ".join(sorted(set(self.run[dtype]))) + for dtype in sorted(self.missing_pkg.keys()): + progs =3D " ".join(sorted(set(self.missing_pkg[dtype]))) =20 try: name =3D DepManager.name(dtype) @@ -158,6 +207,11 @@ class AncillaryMethods: =20 @staticmethod def which(prog): + """ + Our own implementation of which(). We could instead use + shutil.which(), but this function is simple enough. + Probably faster to use this implementation than to import shutil. + """ for path in os.environ.get("PATH", "").split(":"): full_path =3D os.path.join(path, prog) if os.access(full_path, os.X_OK): @@ -167,6 +221,10 @@ class AncillaryMethods: =20 @staticmethod def get_python_version(cmd): + """ + Get python version from a Python binary. As we need to detect if + are out there newer python binaries, we can't rely on sys.release = here. + """ =20 result =3D SphinxDependencyChecker.run([cmd, "--version"], capture_output=3DTrue, text=3D= True) @@ -181,7 +239,13 @@ class AncillaryMethods: =20 @staticmethod def find_python(): + """ + Detect if are out there any python 3.xy version newer than the + current one. =20 + Note: this routine is limited to up to 2 digits for python3. We + may need to update it one day, hopefully on a distant future. + """ patterns =3D [ "python3.[0-9]", "python3.[0-9][0-9]", @@ -200,7 +264,10 @@ class AncillaryMethods: =20 @staticmethod def check_python(): - + """ + Check if the current python binary satisfies our minimal requireme= nt + for Sphinx build. If not, re-run with a newer version if found. + """ cur_ver =3D sys.version_info[:3] if cur_ver >=3D MIN_PYTHON_VERSION: ver =3D ver_str(cur_ver) @@ -240,7 +307,10 @@ class AncillaryMethods: =20 @staticmethod def run(*args, **kwargs): - """Excecute a command, hiding its output by default""" + """ + Excecute a command, hiding its output by default. + Preserve comatibility with older Python versions. + """ =20 capture_output =3D kwargs.pop('capture_output', False) =20 @@ -262,8 +332,15 @@ class AncillaryMethods: return subprocess.run(*args, **kwargs) =20 class MissingCheckers(AncillaryMethods): + """ + Contains some ancillary checkers for different types of binaries and + package managers. + """ =20 def __init__(self, args, texlive): + """ + Initialize its internal variables + """ self.pdf =3D args.pdf self.virtualenv =3D args.virtualenv self.version_check =3D args.version_check @@ -280,17 +357,20 @@ class MissingCheckers(AncillaryMethods): =20 self.install =3D "" =20 - # - # Methods to check if a feature exists - # - def check_missing_file(self, files, package, dtype): + """ + Does the file exists? If not, add it to missing dependencies. + """ for f in files: if os.path.exists(f): return self.deps.add_package(package, dtype) =20 def check_program(self, prog, dtype): + """ + Does the program exists and it is at the PATH? + If not, add it to missing dependencies. + """ found =3D self.which(prog) if found: return found @@ -300,6 +380,18 @@ class MissingCheckers(AncillaryMethods): return None =20 def check_perl_module(self, prog, dtype): + """ + Does perl have a dependency? Is it available? + If not, add it to missing dependencies. + + Right now, we still need Perl for doc build, as it is required + by some tools called at docs or kernel build time, like: + + scripts/documentation-file-ref-check + + Also, checkpatch is on Perl. + """ + # While testing with lxc download template, one of the # distros (Oracle) didn't have perl - nor even an option to install # before installing oraclelinux-release-el9 package. @@ -318,6 +410,10 @@ class MissingCheckers(AncillaryMethods): self.deps.add_package(prog, dtype) =20 def check_python_module(self, module, is_optional=3DFalse): + """ + Does a python module exists outside venv? If not, add it to missing + dependencies. + """ if is_optional: dtype =3D DepManager.PYTHON_OPTIONAL else: @@ -329,6 +425,9 @@ class MissingCheckers(AncillaryMethods): self.deps.add_package(module, dtype) =20 def check_rpm_missing(self, pkgs, dtype): + """ + Does a rpm package exists? If not, add it to missing dependencies. + """ for prog in pkgs: try: self.run(["rpm", "-q", prog], check=3DTrue) @@ -336,6 +435,9 @@ class MissingCheckers(AncillaryMethods): self.deps.add_package(prog, dtype) =20 def check_pacman_missing(self, pkgs, dtype): + """ + Does a pacman package exists? If not, add it to missing dependenci= es. + """ for prog in pkgs: try: self.run(["pacman", "-Q", prog], check=3DTrue) @@ -343,6 +445,9 @@ class MissingCheckers(AncillaryMethods): self.deps.add_package(prog, dtype) =20 def check_missing_tex(self, is_optional=3DFalse): + """ + Does a LaTeX package exists? If not, add it to missing dependencie= s. + """ if is_optional: dtype =3D DepManager.PDF_OPTIONAL else: @@ -371,6 +476,9 @@ class MissingCheckers(AncillaryMethods): self.deps.add_package(package, dtype) =20 def get_sphinx_fname(self): + """ + Gets the binary filename for sphinx-build. + """ if "SPHINXBUILD" in os.environ: return os.environ["SPHINXBUILD"] =20 @@ -386,6 +494,9 @@ class MissingCheckers(AncillaryMethods): return "" =20 def get_sphinx_version(self, cmd): + """ + Gets sphinx-build version. + """ try: result =3D self.run([cmd, "--version"], stdout=3Dsubprocess.PIPE, @@ -404,6 +515,9 @@ class MissingCheckers(AncillaryMethods): return parse_version(match.group(1)) =20 def check_sphinx(self, conf): + """ + Checks Sphinx minimal requirements + """ try: with open(conf, "r", encoding=3D"utf-8") as f: for line in f: @@ -441,6 +555,10 @@ class MissingCheckers(AncillaryMethods): sys.exit(0) =20 def catcheck(self, filename): + """ + Reads a file if it exists, returning as string. + If not found, returns an empty string. + """ if os.path.exists(filename): with open(filename, "r", encoding=3D"utf-8") as f: return f.read().strip() --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D08982F83D9; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=rZCJyWIXXoujR9clT/Xq/Wu3uVGrB+dQ5mxAn24p3CRg6Q1fwMYuhe8X+2yZLrFG6DcSTKsJFD2NpKxNOeHuBcbN2rPvWIDrsNA9jnSza+ZMhnxjKTA1/JrHd3MYF7HEVphFFEpDHxBP/QuoNBZn/jAiJWjFfN4iKlj3mQv5BXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=+W2ENmXHnB15Oyz3OVQYWghVzWvLQQcm9saVuC/Busc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aqC5uOIkQ6O1zqH3D/6c8y08v4pVlCET5JO2314Kc+YJv2igN6ZmOIqZTxyLDQ3Aj5aV/AlcX8bokqrGt95CwvPHVF3I89aea+TrezuZdkzjaY9btOY80rohmvSF3VkJO4gfA0ab5OXeUXcLptkxEgiIrA2pUIENyTe8bOBrc5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hqo3h9nH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hqo3h9nH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC792C4AF16; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=+W2ENmXHnB15Oyz3OVQYWghVzWvLQQcm9saVuC/Busc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqo3h9nHupLJZVEyZT08RG0RMiCQKuuPDCocRlXJOeGKl5xt6fu8gwSd1xZvChUsb FpZhNSH+hy/vjVHL53GDwPds1fSogya4yewEGVzWTAZ7s/LT4Q1ub38PQ5vtELL5Nu oy/gxFCqgrC7IwFAtnl7MZ0xBebR0vqWh9wx6y0+7iybuhtpwE2KF2M8epDnfySz4t UNxZW4PkbjH+/2hAF9T2Tc1f7lzp9RIWr3nDMQ9xbrdz7nvvc/gcOBt+O/o0CQpUum iwOJbC7Fn+w128JA8KYpqkBSbfuEanqz62/9ras7Ppl+64TYw38ek5120a3wLcU5FX Hl0mf2OWi8U+Q== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kXC-43tu; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 31/39] scripts: sphinx-pre-install: add docstring documentation Date: Tue, 12 Aug 2025 17:52:48 +0200 Message-ID: <0cadab2cab3f78ae6d9f378e92a45125fbc5188f.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" This program is somewhat complex. Add some docstring documentation, explaining what each function and class is supposed to do. Most of the focus here were to describe the ancillary functions used to detect dependency needs. The main SphinxDependencyChecker still requires a lot of care, and probably need to be reorganized to clearly split the 4 types of output it produces: - Need to upgrade Python binary; - System install needs; - Virtual env install needs; - Python install needs via system packages, to run Sphinx natively. Yet, for now, I'm happy of having it a lot better documented than its Perl version. - While here, rename a parameter to have its usage better documented. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 110 +++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 1dc3f19804ab..1c96f6692e9a 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -9,6 +9,22 @@ # Don't add changes not compatible with it, it is meant to report # incompatible python versions. =20 +""" +Dependency checker for Sphinx documentation Kernel build. + +This module provides tools to check for all required dependencies needed to +build documentation using Sphinx, including system packages, Python modules +and LaTeX packages for PDF generation. + +It detect packages for a subset of Linux distributions used by Kernel +maintainers, showing hints and missing dependencies. + +The main class SphinxDependencyChecker handles the dependency checking log= ic +and provides recommendations for installing missing packages. It supports = both +system package installations and Python virtual environments. By default, +system pacage install is recommended. +""" + import argparse import os import re @@ -75,7 +91,7 @@ class DepManager: distro namespace, organized by type. - need: total number of needed dependencies. Never cleaned. - optional: total number of optional dependencies. Never cleaned. - - pdf: PDF support is enabled? + - pdf: Is PDF support enabled? """ self.missing =3D {} self.missing_pkg =3D {} @@ -565,6 +581,13 @@ class MissingCheckers(AncillaryMethods): return "" =20 def check_missing(self, progs): + """ + Check for missing dependencies using the provided program mapping. + + The actual distro-specific programs are mapped via progs argument. + + Returns True if there are missing dependencies, False otherwise. + """ self.install +=3D self.deps.check_missing(progs) if self.verbose_warn_install: self.deps.warn_install() @@ -633,8 +656,18 @@ class MissingCheckers(AncillaryMethods): return system_release =20 class SphinxDependencyChecker(MissingCheckers): + """ + Main class for checking Sphinx documentation build dependencies. =20 + - Check for missing system packages; + - Check for missing Python modules; + - Check for missing LaTeX packages needed by PDF generation; + - Propose Sphinx install via Python Virtual environment; + - Propose Sphinx install via distro-specific package install. + """ def __init__(self, args): + """Initialize checker variables""" + # List of required texlive packages on Fedora and OpenSuse texlive =3D { "amsfonts.sty": "texlive-amsfonts", @@ -705,6 +738,9 @@ class SphinxDependencyChecker(MissingCheckers): # =20 def give_debian_hints(self): + """ + Provide package installation hints for Debian-based distros. + """ progs =3D { "Pod::Usage": "perl-modules", "convert": "imagemagick", @@ -745,6 +781,10 @@ class SphinxDependencyChecker(MissingCheckers): print(f"\n\tsudo apt-get install {self.install}") =20 def give_redhat_hints(self): + """ + Provide package installation hints for RedHat-based distros + (Fedora, RHEL and RHEL-based variants). + """ progs =3D { "Pod::Usage": "perl-Pod-Usage", "convert": "ImageMagick", @@ -837,6 +877,10 @@ class SphinxDependencyChecker(MissingCheckers): print(f"\n\tsudo dnf install -y {self.install}") =20 def give_opensuse_hints(self): + """ + Provide package installation hints for openSUSE-based distros + (Leap and Tumbleweed). + """ progs =3D { "Pod::Usage": "perl-Pod-Usage", "convert": "ImageMagick", @@ -909,6 +953,9 @@ class SphinxDependencyChecker(MissingCheckers): print(f"\n\tsudo zypper install --no-recommends {self.install}") =20 def give_mageia_hints(self): + """ + Provide package installation hints for Mageia and OpenMandriva. + """ progs =3D { "Pod::Usage": "perl-Pod-Usage", "convert": "ImageMagick", @@ -956,6 +1003,9 @@ class SphinxDependencyChecker(MissingCheckers): print(f"\n\tsudo {packager_cmd} {self.install}") =20 def give_arch_linux_hints(self): + """ + Provide package installation hints for ArchLinux. + """ progs =3D { "convert": "imagemagick", "dot": "graphviz", @@ -989,6 +1039,9 @@ class SphinxDependencyChecker(MissingCheckers): print(f"\n\tsudo pacman -S {self.install}") =20 def give_gentoo_hints(self): + """ + Provide package installation hints for Gentoo. + """ progs =3D { "convert": "media-gfx/imagemagick", "dot": "media-gfx/graphviz", @@ -1107,7 +1160,12 @@ class SphinxDependencyChecker(MissingCheckers): # =20 def check_distros(self): - # OS-specific hints logic + """ + OS-specific hints logic. Seeks for a hinter. If found, provide + package-manager-specific install commands. + + Otherwise, just lists the missing dependencies. + """ os_hints =3D { re.compile("Red Hat Enterprise Linux"): self.give_redhat_hin= ts, re.compile("Fedora"): self.give_redhat_hin= ts, @@ -1159,10 +1217,22 @@ class SphinxDependencyChecker(MissingCheckers): # Common dependencies # def deactivate_help(self): + """ + Print a helper message to disable a virtual environment. + """ + print("\n If you want to exit the virtualenv, you can use:") print("\tdeactivate") =20 def get_virtenv(self): + """ + Give a hint about how to activate an already-existing virtual + environment containing sphinx-build. + + Returns a tuble with (activate_cmd_path, sphinx_version) with + the newest available virtual env. + """ + cwd =3D os.getcwd() =20 activates =3D [] @@ -1207,6 +1277,14 @@ class SphinxDependencyChecker(MissingCheckers): return ("", ver) =20 def recommend_sphinx_upgrade(self): + """ + Check if Sphinx needs to be upgraded. + + Returns a tuple with the higest available Sphinx version if found. + Otherwise, returns None to indicate either that no upgrade is need= ed + or no venv was found. + """ + # Avoid running sphinx-builds from venv if cur_version is good if self.cur_version and self.cur_version >=3D RECOMMENDED_VERSION: self.latest_avail_ver =3D self.cur_version @@ -1247,6 +1325,9 @@ class SphinxDependencyChecker(MissingCheckers): return self.latest_avail_ver =20 def recommend_package(self): + """ + Recommend installing Sphinx as a distro-specific package. + """ =20 print("\n2) As a package with:") =20 @@ -1270,11 +1351,19 @@ class SphinxDependencyChecker(MissingCheckers): self.verbose_warn_install =3D old_verbose =20 def recommend_sphinx_version(self, virtualenv_cmd): - # The logic here is complex, as it have to deal with different ver= sions: - # - minimal supported version; - # - minimal PDF version; - # - recommended version. - # It also needs to work fine with both distro's package and venv/v= irtualenv + """ + Provide recommendations for installing or upgrading Sphinx based + on current version. + + The logic here is complex, as it have to deal with different versi= ons: + + - minimal supported version; + - minimal PDF version; + - recommended version. + + It also needs to work fine with both distro's package and + venv/virtualenv + """ =20 if self.recommend_python: print("\nPython version is incompatible with doc build.\n" \ @@ -1369,6 +1458,10 @@ class SphinxDependencyChecker(MissingCheckers): "\thttps://github.com/sphinx-doc/sphinx/pull/8313") =20 def check_needs(self): + """ + Main method that checks needed dependencies and provides + recommendations. + """ self.python_cmd =3D sys.executable =20 # Check if Sphinx is already accessible from current environment @@ -1451,6 +1544,7 @@ Process some flags related to Sphinx installation and= documentation build. =20 =20 def main(): + """Main function""" parser =3D argparse.ArgumentParser(description=3DDESCRIPTION) =20 parser.add_argument( @@ -1481,6 +1575,6 @@ def main(): checker.check_python() checker.check_needs() =20 - +# Call main if not used as module if __name__ =3D=3D "__main__": main() --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFB9E2F83D8; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=iA22JMcIydt01giblUvd57SiFsKohaQw0AQqLWV0ITmriOQAtLPWuZqLwJHXfcQj23DGcQRt/tWD2OkqxcV+SObijkOdqTc8gKblugl7MvE/+zknxzU8lyEwBt8JBawbHgOscf++pvyxiL+IUww5Nn9e2qNy3d6mNILSBySU/Iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=wgqUPfvWSrBA5ivsAx4eRsEEzhKN45zQn51pt6lQAvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rk5ESwafhSO2WFNMqjGusuqxSWMhiD9caE2/5Gl5ziQoOs9fMVwEjFchTfGdm1TJki8jkOnquv1zZdi7ybZdJk18Ou+6g9OoqajEqPFTaMtqtsn13tTSB1m4S9ks/d4YbxkV6Seeo1R37MV9AACi2weG6LQZx/4QXxHeurf1yko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KVWlM2p5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KVWlM2p5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6E72C19423; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=wgqUPfvWSrBA5ivsAx4eRsEEzhKN45zQn51pt6lQAvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KVWlM2p5sybpqHreC0thYYlbvhZcCKCNreb+B8RpCyenatfF1yn1fgvUGhGzoDQhD vC7fvfy6ufmIUkFn2vhItHxvqAaUL/QrYkgdqAlx/dlO9DShjpJlhlWd3yOsu/zRYX zsbZSDnbb0ZzEK7oA5hstceeM/X+Jc/qcYlupmF3it2AaHBDB9rvMvVgkTOzKLQU06 OPtLB4hP9I72pASpdSo8qS0D052pU+vD1gw0PL6hmVUDsVTfvkkRbE7qxnq28Xv4Hk aP/5teAMQIxC33zEb2qxnpUOJ5tbN7lQ9m85Fq48MkvnMVhJ7mzeRnVjxkxALM0TSD cfNFNpk5MvnKw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kXG-4AmJ; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 32/39] scripts: sphinx-pre-install: fix several codingstyle issues Date: Tue, 12 Aug 2025 17:52:49 +0200 Message-ID: <5139b18535e1436e4b1773706224a9ec3a386697.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Address most pylint issues. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 1c96f6692e9a..1b11162da9fb 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -2,8 +2,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2017-2025 Mauro Carvalho Chehab # -# pylint: disable=3DC0103,C0114,C0115,C0116,C0301 -# pylint: disable=3DR0902,R0904,R0912,R0915,R1705,R1710,E1121 +# pylint: disable=3DC0103,C0114,C0115,C0116,C0301,C0302 +# pylint: disable=3DR0902,R0904,R0911,R0912,R0914,R0915,R1705,R1710,E1121 =20 # Note: this script requires at least Python 3.6 to run. # Don't add changes not compatible with it, it is meant to report @@ -115,7 +115,7 @@ class DepManager: if dtype[1]: return f"ERROR: {msg} mandatory deps missing" else: - out =3D f"Warning: {msg} optional deps missing" + return f"Warning: {msg} optional deps missing" =20 @staticmethod def is_optional(dtype): @@ -125,7 +125,7 @@ class DepManager: @staticmethod def is_pdf(dtype): """Ancillary routine to report if a dependency is for PDF generati= on""" - if (dtype[0] =3D=3D DepManager._PDF_TYPE): + if dtype[0] =3D=3D DepManager._PDF_TYPE: return True =20 return False @@ -191,8 +191,8 @@ class DepManager: self.missing_pkg[dtype].append(progs.get(prog, prog)) =20 install =3D [] - for dtype in self.missing_pkg.keys(): - install +=3D self.missing_pkg[dtype] + for dtype, pkgs in self.missing_pkg.items(): + install +=3D pkgs =20 return " ".join(sorted(set(install))) =20 @@ -267,8 +267,6 @@ class AncillaryMethods: "python3.[0-9][0-9]", ] =20 - new_python_cmd =3D None - # Seek for a python binary newer than MIN_PYTHON_VERSION for path in os.getenv("PATH", "").split(":"): for pattern in patterns: @@ -276,7 +274,7 @@ class AncillaryMethods: if os.path.isfile(cmd) and os.access(cmd, os.X_OK): version =3D SphinxDependencyChecker.get_python_ver= sion(cmd) if version >=3D MIN_PYTHON_VERSION: - return(cmd) + return cmd =20 @staticmethod def check_python(): @@ -306,8 +304,8 @@ class AncillaryMethods: =20 new_python_cmd =3D SphinxDependencyChecker.find_python() if not new_python_cmd: - print(f"ERROR: Python version {python_ver} is not spported any= more") - print(f" Can't find a new version. This script may fail") + print(f"ERROR: Python version {python_ver} is not spported any= more\n") + print(" Can't find a new version. This script may fail") return =20 # Restart script using the newer version @@ -362,6 +360,9 @@ class MissingCheckers(AncillaryMethods): self.version_check =3D args.version_check self.texlive =3D texlive =20 + self.min_version =3D (0, 0, 0) + self.cur_version =3D (0, 0, 0) + self.deps =3D DepManager(self.pdf) =20 self.need_symlink =3D 0 @@ -370,8 +371,10 @@ class MissingCheckers(AncillaryMethods): self.verbose_warn_install =3D 1 =20 self.virtenv_dir =3D "" - self.install =3D "" + self.python_cmd =3D "" + + self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] =20 def check_missing_file(self, files, package, dtype): """ @@ -542,10 +545,10 @@ class MissingCheckers(AncillaryMethods): self.min_version =3D parse_version(match.group(1)) break except IOError: - sys.exit(f"Can't open {self.conf}") + sys.exit(f"Can't open {conf}") =20 if not self.min_version: - sys.exit(f"Can't get needs_sphinx version from {self.conf}") + sys.exit(f"Can't get needs_sphinx version from {conf}") =20 self.virtenv_dir =3D self.virtenv_prefix[0] + "latest" =20 @@ -709,7 +712,6 @@ class SphinxDependencyChecker(MissingCheckers): self.rec_sphinx_upgrade =3D 0 =20 self.system_release =3D self.get_system_release() - self.python_cmd =3D "" self.activate_cmd =3D "" =20 # Some distros may not have a Sphinx shipped package compatible wi= th @@ -722,8 +724,6 @@ class SphinxDependencyChecker(MissingCheckers): # Certain hints are meant to be shown only once self.first_hint =3D True =20 - self.min_version =3D (0, 0, 0) - self.cur_version =3D (0, 0, 0) self.latest_avail_ver =3D (0, 0, 0) self.venv_ver =3D (0, 0, 0) =20 @@ -731,7 +731,6 @@ class SphinxDependencyChecker(MissingCheckers): =20 self.conf =3D prefix + "Documentation/conf.py" self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" - self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] =20 # # Distro-specific hints methods @@ -814,6 +813,7 @@ class SphinxDependencyChecker(MissingCheckers): =20 if not rel: print("Couldn't identify release number") + noto_sans_redhat =3D None self.pdf =3D False elif re.search("Fedora", self.system_release): # Fedora 38 and upper use this CJK font @@ -1111,7 +1111,7 @@ class SphinxDependencyChecker(MissingCheckers): for fname, portage in portages.items(): install =3D False =20 - while install =3D=3D False: + while install is False: if not files: # No files under package.usage. Install all install =3D True @@ -1335,7 +1335,7 @@ class SphinxDependencyChecker(MissingCheckers): old_optional =3D self.deps.optional =20 self.pdf =3D False - self.optional =3D 0 + self.deps.optional =3D 0 self.install =3D "" old_verbose =3D self.verbose_warn_install self.verbose_warn_install =3D 0 @@ -1346,8 +1346,8 @@ class SphinxDependencyChecker(MissingCheckers): =20 self.check_distros() =20 - self.need =3D old_need - self.optional =3D old_optional + self.deps.need =3D old_need + self.deps.optional =3D old_optional self.verbose_warn_install =3D old_verbose =20 def recommend_sphinx_version(self, virtualenv_cmd): @@ -1528,13 +1528,13 @@ class SphinxDependencyChecker(MissingCheckers): self.recommend_sphinx_version(virtualenv_cmd) print("") =20 - if not self.optional: + if not self.deps.optional: print("All optional dependencies are met.") =20 - if self.need =3D=3D 1: + if self.deps.need =3D=3D 1: sys.exit("Can't build as 1 mandatory dependency is missing") - elif self.need: - sys.exit(f"Can't build as {self.need} mandatory dependencies a= re missing") + elif self.deps.need: + sys.exit(f"Can't build as {self.deps.need} mandatory dependenc= ies are missing") =20 print("Needed package dependencies are met.") =20 --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7BF92F83C6; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=nK/Q7MAvDTHLLmGNXFFDOnRlII21DUprQKpwqOBVcNAmsXjYecStHB7+D9x77UsN0W0xd1vtsHSRaHBdFL4HixVlJ1padz/LWXxsDu3M+lT9RW8HtRdP5r7DQL5PYEU4N3u9Qp1BuhRtsOqqdGL3b9cpcGt9fk6BE3Fk/shuumU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=EfKmBy4QIHSzGscGS5Y8OctZQzKZJ5DYq4JstfRaNUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YVTgU2ZmCeE2xsVKq2I9XJ7bgW1+sqNjhB8Jm6XynXrJdMSagen3cy5kUM5kqgKGKHeBYYbgN0d4Bm50cZqhGpDrLgyjvEyK3CcYqgaOLvChBumk5Vr/qrGtCuE3zeVVy/dUVkSSgWX5L9hP0Vcg36KkMOWl/nrLTjfKFEUxV/0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L6dIQV36; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L6dIQV36" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2D13C2BCAF; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=EfKmBy4QIHSzGscGS5Y8OctZQzKZJ5DYq4JstfRaNUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L6dIQV36U7+hp935zIBXvRB9oYiU62/WJCsd8Q4IEeqMF3Dj9adcK8oDaUK+p3FKz Z/YpG0IkffbL94H510pdfQlyLm2xin2tiSVgwOVBVy4T+oZCpYltLEIgV8PDWvthwM RcT1VTD1GcHE3jbtrnHXzwW8APRfAzx7pqdC2+XAY3mxPRnxl0T0o/C8wAqN1Kl4H8 CV6uhmdH6L+vKzveWd74U2TwhVpu1/hGw6JmkFwuSwaMXxt8Iwfehs9VD6mt6XfUta ssPFB1g6QwRke09mib1bQZRkT8WSuZl7Wp7/Ds18wwfkSbqBppHeST/YYV2T59aFpc 8r6SLmi3lZcmw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXK-07sO; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 33/39] scripts: sphinx-pre-install: rework install command logic Date: Tue, 12 Aug 2025 17:52:50 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Cleanup the code to remove some redundancy and to let it be clearer about the command install instructions. Ensure that special instructions will be shown only once, before the actual install command. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 179 ++++++++++++++++------------------ 1 file changed, 82 insertions(+), 97 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 1b11162da9fb..7dfe5c2a6cc2 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -213,7 +213,7 @@ class DepManager: raise KeyError(f"ERROR!!!: invalid dtype for {progs}: {dty= pe}") =20 if output_msg: - print(f"\n{output_msg}\n") + print(f"\n{output_msg}") =20 class AncillaryMethods: """ @@ -583,23 +583,6 @@ class MissingCheckers(AncillaryMethods): return f.read().strip() return "" =20 - def check_missing(self, progs): - """ - Check for missing dependencies using the provided program mapping. - - The actual distro-specific programs are mapped via progs argument. - - Returns True if there are missing dependencies, False otherwise. - """ - self.install +=3D self.deps.check_missing(progs) - if self.verbose_warn_install: - self.deps.warn_install() - - if not self.deps.need and not self.deps.optional: - return False - - return True - def get_system_release(self): """ Determine the system type. There's no unique way that would work @@ -722,7 +705,7 @@ class SphinxDependencyChecker(MissingCheckers): self.recommend_python =3D None =20 # Certain hints are meant to be shown only once - self.first_hint =3D True + self.distro_msg =3D None =20 self.latest_avail_ver =3D (0, 0, 0) self.venv_ver =3D (0, 0, 0) @@ -732,6 +715,33 @@ class SphinxDependencyChecker(MissingCheckers): self.conf =3D prefix + "Documentation/conf.py" self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" =20 + def get_install_progs(self, progs, cmd, extra=3DNone): + """ + Check for missing dependencies using the provided program mapping. + + The actual distro-specific programs are mapped via progs argument. + """ + install =3D self.deps.check_missing(progs) + + if self.verbose_warn_install: + self.deps.warn_install() + + if not install: + return + + if cmd: + if self.verbose_warn_install: + msg =3D "You should run:" + else: + msg =3D "" + + if extra: + msg +=3D "\n\t" + extra.replace("\n", "\n\t") + + return(msg + "\n\tsudo " + cmd + " " + install) + + return None + # # Distro-specific hints methods # @@ -772,12 +782,7 @@ class SphinxDependencyChecker(MissingCheckers): =20 self.check_program("dvipng", DepManager.PDF_MANDATORY) =20 - if self.check_missing(progs): - return - - if self.verbose_warn_install: - print("You should run:") - print(f"\n\tsudo apt-get install {self.install}") + return self.get_install_progs(progs, "apt-get install") =20 def give_redhat_hints(self): """ @@ -838,18 +843,16 @@ class SphinxDependencyChecker(MissingCheckers): self.deps.add_package("python39", DepManager.SYSTEM_MANDAT= ORY) self.recommend_python =3D True =20 - if self.first_hint: - print("Note: RHEL-based distros typically require extra re= positories.\n" \ - "For most, enabling epel and crb are enough:\n" \ - "\tsudo dnf install -y epel-release", \ - "\tsudo dnf config-manager --set-enabled crb\n" \ - "Yet, some may have other required repositories. Tho= se commands could be useful:\n" \ - "\tsudo dnf repolist all\n" \ - "\tsudo dnf repoquery --available --info \n", - "\tsudo dnf config-manager --set-enabled '*' # enabl= e all - probably not what you want") - - self.first_hint =3D False - + if not self.distro_msg: + self.distro_msg =3D \ + "Note: RHEL-based distros typically require extra repo= sitories.\n" \ + "For most, enabling epel and crb are enough:\n" \ + "\tsudo dnf install -y epel-release\n" \ + "\tsudo dnf config-manager --set-enabled crb\n" \ + "Yet, some may have other required repositories. Those= commands could be useful:\n" \ + "\tsudo dnf repolist all\n" \ + "\tsudo dnf repoquery --available --info \n" \ + "\tsudo dnf config-manager --set-enabled '*' # enable = all - probably not what you want" =20 if self.pdf: pdf_pkgs =3D [ @@ -868,13 +871,7 @@ class SphinxDependencyChecker(MissingCheckers): if not fedora and rel =3D=3D 8: self.deps.del_package("texlive-ctex") =20 - if self.check_missing(progs): - return - - if self.verbose_warn_install: - print("You should run:") - - print(f"\n\tsudo dnf install -y {self.install}") + return self.get_install_progs(progs, "dnf install") =20 def give_opensuse_hints(self): """ @@ -945,12 +942,7 @@ class SphinxDependencyChecker(MissingCheckers): if self.pdf: self.check_missing_tex() =20 - if self.check_missing(progs): - return - - if self.verbose_warn_install: - print("You should run:") - print(f"\n\tsudo zypper install --no-recommends {self.install}") + return self.get_install_progs(progs, "zypper install --no-recommen= ds") =20 def give_mageia_hints(self): """ @@ -995,12 +987,7 @@ class SphinxDependencyChecker(MissingCheckers): self.check_missing_file(pdf_pkgs, noto_sans, DepManager.PDF_MA= NDATORY) self.check_rpm_missing(tex_pkgs, DepManager.PDF_MANDATORY) =20 - if self.check_missing(progs): - return - - if self.verbose_warn_install: - print("You should run:") - print(f"\n\tsudo {packager_cmd} {self.install}") + return self.get_install_progs(progs, packager_cmd) =20 def give_arch_linux_hints(self): """ @@ -1023,20 +1010,15 @@ class SphinxDependencyChecker(MissingCheckers): ] =20 if self.pdf: - self.check_pacman_missing(archlinux_tex_pkgs, DepManager.PDF_M= ANDATORY) + self.check_pacman_missing(archlinux_tex_pkgs, + DepManager.PDF_MANDATORY) =20 - self.check_missing_file( - ["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], - "noto-fonts-cjk", - 2, - ) + self.check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJ= K-Regular.ttc"], + "noto-fonts-cjk", + DepManager.PDF_MANDATORY) =20 - if self.check_missing(progs): - return =20 - if self.verbose_warn_install: - print("You should run:") - print(f"\n\tsudo pacman -S {self.install}") + return self.get_install_progs(progs, "pacman -S") =20 def give_gentoo_hints(self): """ @@ -1065,13 +1047,6 @@ class SphinxDependencyChecker(MissingCheckers): for package, files in pdf_pkgs.items(): self.check_missing_file(files, package, DepManager.PDF_MAN= DATORY) =20 - if self.check_missing(progs): - return - - if self.verbose_warn_install: - print("You should run:") - print("\n") - # Handling dependencies is a nightmare, as Gentoo refuses to emerge # some packages if there's no package.use file describing them. # To make it worse, compilation flags shall also be present there @@ -1104,7 +1079,10 @@ class SphinxDependencyChecker(MissingCheckers): "zziblib": "dev-libs/zziplib sdl", } =20 - if self.first_hint: + extra_cmds =3D "" + if not self.distro_msg: + self.distro_msg =3D "Note: Gentoo requires package.use to be a= djusted before emerging packages" + use_base =3D "/etc/portage/package.use" files =3D glob(f"{use_base}/*") =20 @@ -1148,23 +1126,23 @@ class SphinxDependencyChecker(MissingCheckers): =20 # emit a code to setup missing USE if install: - print(f"\tsudo su -c 'echo \"{portage}\" > {use_base}/= {fname}'") - - self.first_hint =3D False + extra_cmds +=3D (f"sudo su -c 'echo \"{portage}\" > {u= se_base}/{fname}'\n") =20 # Now, we can use emerge and let it respect USE - print(f"\tsudo emerge --ask --changed-use --binpkg-respect-use=3Dy= {self.install}") + return self.get_install_progs(progs, + "emerge --ask --changed-use --binpkg= -respect-use=3Dy", + extra_cmds) =20 - # - # Dispatch the check to an os_specific hinter - # - - def check_distros(self): + def get_install(self): """ - OS-specific hints logic. Seeks for a hinter. If found, provide - package-manager-specific install commands. + OS-specific hints logic. Seeks for a hinter. If found, use it to + provide package-manager specific install commands. =20 - Otherwise, just lists the missing dependencies. + Otherwise, outputs install instructions for the meta-packages. + + Returns a string with the command to be executed to install the + the needed packages, if distro found. Otherwise, return just a + list of packages that require installation. """ os_hints =3D { re.compile("Red Hat Enterprise Linux"): self.give_redhat_hin= ts, @@ -1195,9 +1173,7 @@ class SphinxDependencyChecker(MissingCheckers): # If the OS is detected, use per-OS hint logic for regex, os_hint in os_hints.items(): if regex.search(self.system_release): - os_hint() - - return + return os_hint() =20 # # Fall-back to generic hint code for other distros @@ -1207,11 +1183,12 @@ class SphinxDependencyChecker(MissingCheckers): if self.pdf: self.check_missing_tex() =20 - self.check_missing(progs) + self.distro_msg =3D \ + f"I don't know distro {self.system_release}.\n" \ + "So, I can't provide you a hint with the install procedure.\n"= \ + "There are likely missing dependencies.\n" =20 - print(f"I don't know distro {self.system_release}.") - print("So, I can't provide you a hint with the install procedure.") - print("There are likely missing dependencies.") + return self.get_install_progs(progs, None) =20 # # Common dependencies @@ -1336,7 +1313,6 @@ class SphinxDependencyChecker(MissingCheckers): =20 self.pdf =3D False self.deps.optional =3D 0 - self.install =3D "" old_verbose =3D self.verbose_warn_install self.verbose_warn_install =3D 0 =20 @@ -1344,7 +1320,9 @@ class SphinxDependencyChecker(MissingCheckers): =20 self.deps.add_package("python-sphinx", DepManager.PYTHON_MANDATORY) =20 - self.check_distros() + cmd =3D self.get_install() + if cmd: + print(cmd) =20 self.deps.need =3D old_need self.deps.optional =3D old_optional @@ -1511,7 +1489,14 @@ class SphinxDependencyChecker(MissingCheckers): self.check_program("latexmk", DepManager.PDF_MANDATORY) =20 # Do distro-specific checks and output distro-install commands - self.check_distros() + cmd =3D self.get_install() + if cmd: + print(cmd) + + # If distro requires some special instructions, print here. + # Please notice that get_install() needs to be called first. + if self.distro_msg: + print("\n" + self.distro_msg) =20 if not self.python_cmd: if self.need =3D=3D 1: --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9F32F83AD; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=uurZX7Zf9AQg4pDMB50G+fc0TgX7of90XeHKPIME8xyNXnITIqKv08Qt2f2cjvscC4DmontCA9h8RpnAQMZnh4tslpy8/HRbKWpDuAzi7zI01Ly8EMg0IhlIbmbcovDqx0HhlGpVyilYeB8HQiUiD4M+2Tv1cJ29VYHCQbuRhcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=NhgG4sjcH9+6fFNfAF3TJRGpggJZFcRXYZTyaE/c0uI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ka/Uq6LoaDy628ac3g/HSx0zXgeGXktEYS9U1NtcLUQOSsGzsmQ0v/tDHQMI/nE1a4DDaIlPmfV75MPfNqjY9LaEJb7KLIYSSwi3V4mGdh+VT7GnW8eUiE9Soyj1gyCC5ZIRmKfWnRGKWLR1BKyT1MTQS/javfQHaDOLAz/hOZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OYlHG4wz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OYlHG4wz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F21DDC2BC9E; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=NhgG4sjcH9+6fFNfAF3TJRGpggJZFcRXYZTyaE/c0uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYlHG4wzcz0x4Ey4MvsCg0H3+2Umh2AMl28z5AJEHT8cITd+ai09gCt7wa1ChbjNK jiWh9vs0kybDJFFX+nEcJwDc03z0d6w33gNq07p7PvdO2J9zSI5fY0GmctO5r/ydwB rcvGvV4IYKsgC0S/tD1Ma8moxHP1p2cB5XQTDSJLhMPNSpcAX9ol32sft9l0nbvM8s 4FXPmnotvtEyPRc2L74B40XSaIaMTHOfQ/AMtI6WaX+/ZVEdsZ7NTtgzpKsY2OxsM7 FOMH/YohJN6NPCv2w6BiHFwsR6RU41Z0oJyxDw3jecBbqdxntVXuQvJzNbioxIDF0E yGFSyywez0YPQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXO-0Ehk; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 34/39] docs: Makefile: switch to the new scripts/sphinx-pre-install.py Date: Tue, 12 Aug 2025 17:52:51 +0200 Message-ID: <79508fb071512c33e807f5411bbff1904751b5d3.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Now that we have a better, improved Python script, use it when checking for documentation build dependencies. Signed-off-by: Mauro Carvalho Chehab --- Documentation/Makefile | 14 +++++++------- .../{sphinx-pre-install.py =3D> sphinx-pre-install} | 0 2 files changed, 7 insertions(+), 7 deletions(-) rename scripts/{sphinx-pre-install.py =3D> sphinx-pre-install} (100%) diff --git a/Documentation/Makefile b/Documentation/Makefile index c486fe3cc5e1..b98477df5ddf 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -46,7 +46,7 @@ ifeq ($(HAVE_SPHINX),0) .DEFAULT: $(warning The '$(SPHINXBUILD)' command was not found. Make sure you have = Sphinx installed and in PATH, or set the SPHINXBUILD make variable to point= to the full path of the '$(SPHINXBUILD)' executable.) @echo - @$(srctree)/scripts/sphinx-pre-install.pl + @$(srctree)/scripts/sphinx-pre-install @echo " SKIP Sphinx $@ target." =20 else # HAVE_SPHINX @@ -121,7 +121,7 @@ $(YNL_RST_DIR)/%.rst: $(YNL_YAML_DIR)/%.yaml $(YNL_TOOL) htmldocs texinfodocs latexdocs epubdocs xmldocs: $(YNL_INDEX) =20 htmldocs: - @$(srctree)/scripts/sphinx-pre-install.pl --version-check + @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) =20 # If Rust support is available and .config exists, add rustdoc generated c= ontents. @@ -135,7 +135,7 @@ endif endif =20 texinfodocs: - @$(srctree)/scripts/sphinx-pre-install.pl --version-check + @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texin= fo,$(var))) =20 # Note: the 'info' Make target is generated by sphinx itself when @@ -147,7 +147,7 @@ linkcheckdocs: @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(v= ar))) =20 latexdocs: - @$(srctree)/scripts/sphinx-pre-install.pl --version-check + @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$= (var))) =20 ifeq ($(HAVE_PDFLATEX),0) @@ -160,7 +160,7 @@ else # HAVE_PDFLATEX =20 pdfdocs: DENY_VF =3D XDG_CONFIG_HOME=3D$(FONTS_CONF_DENY_VF) pdfdocs: latexdocs - @$(srctree)/scripts/sphinx-pre-install.pl --version-check + @$(srctree)/scripts/sphinx-pre-install --version-check $(foreach var,$(SPHINXDIRS), \ $(MAKE) PDFLATEX=3D"$(PDFLATEX)" LATEXOPTS=3D"$(LATEXOPTS)" $(DENY_VF)= -C $(BUILDDIR)/$(var)/latex || sh $(srctree)/scripts/check-variable-fonts.= sh || exit; \ mkdir -p $(BUILDDIR)/$(var)/pdf; \ @@ -170,11 +170,11 @@ pdfdocs: latexdocs endif # HAVE_PDFLATEX =20 epubdocs: - @$(srctree)/scripts/sphinx-pre-install.pl --version-check + @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(v= ar))) =20 xmldocs: - @$(srctree)/scripts/sphinx-pre-install.pl --version-check + @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var= ))) =20 endif # HAVE_SPHINX diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install similarity index 100% rename from scripts/sphinx-pre-install.py rename to scripts/sphinx-pre-install --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5A262F83CD; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=o2F6GEjMLmaKcCyF6ViKas88d628OCxOPOHLyL/o7f71MjmJVJdw1ds2VGyz5tu7R6aPEArV/kqVnwUo2/Wt6XiLWWC4mQR/DzoaPki1i8hDdoK9dDQlQq2OMwyh64bXF9lmjFiQ7bOvQvOTWwCg1BV9ybZtcB6dMwro7UXkG1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=3Y20UtugBZQI5o8dH0DRFzjO8ktdEynnNegI0CdQerE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O1s3al2JTYVeRSRVjOOrURVN5KqhPerQvHfncccfJE8WDaYkdjGeTHonzqF65vDZVEv9UewFWIxf/MZYRhpFroKSoNdJKB1coYlOddUiUIdbSwHB8U/064P1bnBGEwlXLnqI1ABGAZNXtOUT453tcbSWkV1k1AfgskaiIIiji3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZbkJXHs8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZbkJXHs8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F067BC19425; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=3Y20UtugBZQI5o8dH0DRFzjO8ktdEynnNegI0CdQerE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZbkJXHs8/2RURGHRd2l19C9NFX17+/4jXXCdxRs5qoevaxBOintzAjgiROjTbVDDq q56JgSplntJ0Hu7ageLhcinNRTnxTilpqQa+rutX6CAkuyhvAL1dfbx5enZnVHZ/Ue lLExFnIHI58UQEx3ECDX/qnVdIw4YGdBgmpgHLZPBIgazlvh1UEc5Ejw4WdR0L5ujK u5leP13JJGm0TqOsXM0MtvuqNXeB399HwMHYmc7mKiMua+ZkTUsB9HUBoLULGtBb8n s+0FIqok/bL885C6G7Tw8DCm4z+DZKbnPAwr8IrjevgSvqffTYHpfu5/R+hxOstlJz 7iwOkN36Uv+WA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXS-0Ldt; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 35/39] scripts: sphinx-pre-install.pl: get rid of the old script Date: Tue, 12 Aug 2025 17:52:52 +0200 Message-ID: <6900872e6b89b7ff304e70f5d1c23cbb3c757d28.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" All features were ported to the Python version. Plus, it supports more variants and contain fixes. So, drop the old version. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.pl | 1056 --------------------------------- 1 file changed, 1056 deletions(-) delete mode 100755 scripts/sphinx-pre-install.pl diff --git a/scripts/sphinx-pre-install.pl b/scripts/sphinx-pre-install.pl deleted file mode 100755 index 07234d482fa8..000000000000 --- a/scripts/sphinx-pre-install.pl +++ /dev/null @@ -1,1056 +0,0 @@ -#!/usr/bin/env perl -# SPDX-License-Identifier: GPL-2.0-or-later -use strict; - -# Copyright (c) 2017-2020 Mauro Carvalho Chehab -# - -my $prefix =3D "./"; -$prefix =3D "$ENV{'srctree'}/" if ($ENV{'srctree'}); - -my $conf =3D $prefix . "Documentation/conf.py"; -my $requirement_file =3D $prefix . "Documentation/sphinx/requirements.txt"; -my $virtenv_prefix =3D "sphinx_"; - -# -# Static vars -# - -my %missing; -my $system_release; -my $need =3D 0; -my $optional =3D 0; -my $need_symlink =3D 0; -my $need_sphinx =3D 0; -my $need_pip =3D 0; -my $need_virtualenv =3D 0; -my $rec_sphinx_upgrade =3D 0; -my $verbose_warn_install =3D 1; -my $install =3D ""; -my $virtenv_dir =3D ""; -my $python_cmd =3D ""; -my $activate_cmd; -my $min_version; -my $cur_version; -my $rec_version =3D "3.4.3"; -my $latest_avail_ver; - -# -# Command line arguments -# - -my $pdf =3D 1; -my $virtualenv =3D 1; -my $version_check =3D 0; - -# -# List of required texlive packages on Fedora and OpenSuse -# - -my %texlive =3D ( - 'amsfonts.sty' =3D> 'texlive-amsfonts', - 'amsmath.sty' =3D> 'texlive-amsmath', - 'amssymb.sty' =3D> 'texlive-amsfonts', - 'amsthm.sty' =3D> 'texlive-amscls', - 'anyfontsize.sty' =3D> 'texlive-anyfontsize', - 'atbegshi.sty' =3D> 'texlive-oberdiek', - 'bm.sty' =3D> 'texlive-tools', - 'capt-of.sty' =3D> 'texlive-capt-of', - 'cmap.sty' =3D> 'texlive-cmap', - 'ecrm1000.tfm' =3D> 'texlive-ec', - 'eqparbox.sty' =3D> 'texlive-eqparbox', - 'eu1enc.def' =3D> 'texlive-euenc', - 'fancybox.sty' =3D> 'texlive-fancybox', - 'fancyvrb.sty' =3D> 'texlive-fancyvrb', - 'float.sty' =3D> 'texlive-float', - 'fncychap.sty' =3D> 'texlive-fncychap', - 'footnote.sty' =3D> 'texlive-mdwtools', - 'framed.sty' =3D> 'texlive-framed', - 'luatex85.sty' =3D> 'texlive-luatex85', - 'multirow.sty' =3D> 'texlive-multirow', - 'needspace.sty' =3D> 'texlive-needspace', - 'palatino.sty' =3D> 'texlive-psnfss', - 'parskip.sty' =3D> 'texlive-parskip', - 'polyglossia.sty' =3D> 'texlive-polyglossia', - 'tabulary.sty' =3D> 'texlive-tabulary', - 'threeparttable.sty' =3D> 'texlive-threeparttable', - 'titlesec.sty' =3D> 'texlive-titlesec', - 'ucs.sty' =3D> 'texlive-ucs', - 'upquote.sty' =3D> 'texlive-upquote', - 'wrapfig.sty' =3D> 'texlive-wrapfig', - 'ctexhook.sty' =3D> 'texlive-ctex', -); - -# -# Subroutines that checks if a feature exists -# - -sub check_missing(%) -{ - my %map =3D %{$_[0]}; - - foreach my $prog (sort keys %missing) { - my $is_optional =3D $missing{$prog}; - - # At least on some LTS distros like CentOS 7, texlive doesn't - # provide all packages we need. When such distros are - # detected, we have to disable PDF output. - # - # So, we need to ignore the packages that distros would - # need for LaTeX to work - if ($is_optional =3D=3D 2 && !$pdf) { - $optional--; - next; - } - - if ($verbose_warn_install) { - if ($is_optional) { - print "Warning: better to also install \"$prog\".\n"; - } else { - print "ERROR: please install \"$prog\", otherwise, build won't work.\n= "; - } - } - if (defined($map{$prog})) { - $install .=3D " " . $map{$prog}; - } else { - $install .=3D " " . $prog; - } - } - - $install =3D~ s/^\s//; -} - -sub add_package($$) -{ - my $package =3D shift; - my $is_optional =3D shift; - - $missing{$package} =3D $is_optional; - if ($is_optional) { - $optional++; - } else { - $need++; - } -} - -sub check_missing_file($$$) -{ - my $files =3D shift; - my $package =3D shift; - my $is_optional =3D shift; - - for (@$files) { - return if(-e $_); - } - - add_package($package, $is_optional); -} - -sub findprog($) -{ - foreach(split(/:/, $ENV{PATH})) { - return "$_/$_[0]" if(-x "$_/$_[0]"); - } -} - -sub find_python_no_venv() -{ - my $prog =3D shift; - - my $cur_dir =3D qx(pwd); - $cur_dir =3D~ s/\s+$//; - - foreach my $dir (split(/:/, $ENV{PATH})) { - next if ($dir =3D~ m,($cur_dir)/sphinx,); - return "$dir/python3" if(-x "$dir/python3"); - } - foreach my $dir (split(/:/, $ENV{PATH})) { - next if ($dir =3D~ m,($cur_dir)/sphinx,); - return "$dir/python" if(-x "$dir/python"); - } - return "python"; -} - -sub check_program($$) -{ - my $prog =3D shift; - my $is_optional =3D shift; - - return $prog if findprog($prog); - - add_package($prog, $is_optional); -} - -sub check_perl_module($$) -{ - my $prog =3D shift; - my $is_optional =3D shift; - - my $err =3D system("perl -M$prog -e 1 2>/dev/null /dev/null"); - return if ($err =3D=3D 0); - - add_package($prog, $is_optional); -} - -sub check_python_module($$) -{ - my $prog =3D shift; - my $is_optional =3D shift; - - return if (!$python_cmd); - - my $err =3D system("$python_cmd -c 'import $prog' 2>/dev/null /dev/null"); - return if ($err =3D=3D 0); - - add_package($prog, $is_optional); -} - -sub check_rpm_missing($$) -{ - my @pkgs =3D @{$_[0]}; - my $is_optional =3D $_[1]; - - foreach my $prog(@pkgs) { - my $err =3D system("rpm -q '$prog' 2>/dev/null >/dev/null"); - add_package($prog, $is_optional) if ($err); - } -} - -sub check_pacman_missing($$) -{ - my @pkgs =3D @{$_[0]}; - my $is_optional =3D $_[1]; - - foreach my $prog(@pkgs) { - my $err =3D system("pacman -Q '$prog' 2>/dev/null >/dev/null"); - add_package($prog, $is_optional) if ($err); - } -} - -sub check_missing_tex($) -{ - my $is_optional =3D shift; - my $kpsewhich =3D findprog("kpsewhich"); - - foreach my $prog(keys %texlive) { - my $package =3D $texlive{$prog}; - if (!$kpsewhich) { - add_package($package, $is_optional); - next; - } - my $file =3D qx($kpsewhich $prog); - add_package($package, $is_optional) if ($file =3D~ /^\s*$/); - } -} - -sub get_sphinx_fname() -{ - if ($ENV{'SPHINXBUILD'}) { - return $ENV{'SPHINXBUILD'}; - } - - my $fname =3D "sphinx-build"; - return $fname if findprog($fname); - - $fname =3D "sphinx-build-3"; - if (findprog($fname)) { - $need_symlink =3D 1; - return $fname; - } - - return ""; -} - -sub get_sphinx_version($) -{ - my $cmd =3D shift; - my $ver; - - open IN, "$cmd --version 2>&1 |"; - while () { - if (m/^\s*sphinx-build\s+([\d\.]+)((\+\/[\da-f]+)|(b\d+))?$/) { - $ver=3D$1; - last; - } - # Sphinx 1.2.x uses a different format - if (m/^\s*Sphinx.*\s+([\d\.]+)$/) { - $ver=3D$1; - last; - } - } - close IN; - return $ver; -} - -sub check_sphinx() -{ - open IN, $conf or die "Can't open $conf"; - while () { - if (m/^\s*needs_sphinx\s*=3D\s*[\'\"]([\d\.]+)[\'\"]/) { - $min_version=3D$1; - last; - } - } - close IN; - - die "Can't get needs_sphinx version from $conf" if (!$min_version); - - $virtenv_dir =3D $virtenv_prefix . "latest"; - - my $sphinx =3D get_sphinx_fname(); - if ($sphinx eq "") { - $need_sphinx =3D 1; - return; - } - - $cur_version =3D get_sphinx_version($sphinx); - die "$sphinx didn't return its version" if (!$cur_version); - - if ($cur_version lt $min_version) { - printf "ERROR: Sphinx version is %s. It should be >=3D %s\n", - $cur_version, $min_version; - $need_sphinx =3D 1; - return; - } - - return if ($cur_version lt $rec_version); - - # On version check mode, just assume Sphinx has all mandatory deps - exit (0) if ($version_check); -} - -# -# Ancillary subroutines -# - -sub catcheck($) -{ - my $res =3D ""; - $res =3D qx(cat $_[0]) if (-r $_[0]); - return $res; -} - -sub which($) -{ - my $file =3D shift; - my @path =3D split ":", $ENV{PATH}; - - foreach my $dir(@path) { - my $name =3D $dir.'/'.$file; - return $name if (-x $name ); - } - return undef; -} - -# -# Subroutines that check distro-specific hints -# - -sub give_debian_hints() -{ - my %map =3D ( - "python-sphinx" =3D> "python3-sphinx", - "yaml" =3D> "python3-yaml", - "ensurepip" =3D> "python3-venv", - "virtualenv" =3D> "virtualenv", - "dot" =3D> "graphviz", - "convert" =3D> "imagemagick", - "Pod::Usage" =3D> "perl-modules", - "xelatex" =3D> "texlive-xetex", - "rsvg-convert" =3D> "librsvg2-bin", - ); - - if ($pdf) { - check_missing_file(["/usr/share/texlive/texmf-dist/tex/latex/ctex/ctexho= ok.sty"], - "texlive-lang-chinese", 2); - - check_missing_file(["/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"], - "fonts-dejavu", 2); - - check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", - "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", - "/usr/share/fonts/opentype/noto/NotoSerifCJK-Regular.ttc"], - "fonts-noto-cjk", 2); - } - - check_program("dvipng", 2) if ($pdf); - check_missing(\%map); - - return if (!$need && !$optional); - printf("You should run:\n") if ($verbose_warn_install); - printf("\n\tsudo apt-get install $install\n"); -} - -sub give_redhat_hints() -{ - my %map =3D ( - "python-sphinx" =3D> "python3-sphinx", - "yaml" =3D> "python3-pyyaml", - "virtualenv" =3D> "python3-virtualenv", - "dot" =3D> "graphviz", - "convert" =3D> "ImageMagick", - "Pod::Usage" =3D> "perl-Pod-Usage", - "xelatex" =3D> "texlive-xetex-bin", - "rsvg-convert" =3D> "librsvg2-tools", - ); - - my @fedora26_opt_pkgs =3D ( - "graphviz-gd", # Fedora 26: needed for PDF support - ); - - my @fedora_tex_pkgs =3D ( - "texlive-collection-fontsrecommended", - "texlive-collection-latex", - "texlive-xecjk", - "dejavu-sans-fonts", - "dejavu-serif-fonts", - "dejavu-sans-mono-fonts", - ); - - # - # Checks valid for RHEL/CentOS version 7.x. - # - my $old =3D 0; - my $rel; - my $noto_sans_redhat =3D "google-noto-sans-cjk-ttc-fonts"; - $rel =3D $2 if ($system_release =3D~ /(release|Linux)\s+(\d+)/); - - if (!($system_release =3D~ /Fedora/)) { - $map{"virtualenv"} =3D "python-virtualenv"; - - if ($rel && $rel < 8) { - $old =3D 1; - $pdf =3D 0; - - printf("Note: texlive packages on RHEL/CENTOS <=3D 7 are incomplete. Ca= n't support PDF output\n"); - printf("If you want to build PDF, please read:\n"); - printf("\thttps://www.systutorials.com/241660/how-to-install-tex-live-o= n-centos-7-linux/\n"); - } - } else { - if ($rel && $rel < 26) { - $old =3D 1; - } - if ($rel && $rel >=3D 38) { - $noto_sans_redhat =3D "google-noto-sans-cjk-fonts"; - } - } - if (!$rel) { - printf("Couldn't identify release number\n"); - $old =3D 1; - $pdf =3D 0; - } - - if ($pdf) { - check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regula= r.ttc", - "/usr/share/fonts/google-noto-sans-cjk-fonts/NotoSansCJK-Regular.t= tc"], - $noto_sans_redhat, 2); - } - - check_rpm_missing(\@fedora26_opt_pkgs, 2) if ($pdf && !$old); - check_rpm_missing(\@fedora_tex_pkgs, 2) if ($pdf); - check_missing_tex(2) if ($pdf); - check_missing(\%map); - - return if (!$need && !$optional); - - if (!$old) { - # dnf, for Fedora 18+ - printf("You should run:\n") if ($verbose_warn_install); - printf("\n\tsudo dnf install -y $install\n"); - } else { - # yum, for RHEL (and clones) or Fedora version < 18 - printf("You should run:\n") if ($verbose_warn_install); - printf("\n\tsudo yum install -y $install\n"); - } -} - -sub give_opensuse_hints() -{ - my %map =3D ( - "python-sphinx" =3D> "python3-sphinx", - "yaml" =3D> "python3-pyyaml", - "virtualenv" =3D> "python3-virtualenv", - "dot" =3D> "graphviz", - "convert" =3D> "ImageMagick", - "Pod::Usage" =3D> "perl-Pod-Usage", - "xelatex" =3D> "texlive-xetex-bin", - ); - - # On Tumbleweed, this package is also named rsvg-convert - $map{"rsvg-convert"} =3D "rsvg-view" if (!($system_release =3D~ /Tumblewe= ed/)); - - my @suse_tex_pkgs =3D ( - "texlive-babel-english", - "texlive-caption", - "texlive-colortbl", - "texlive-courier", - "texlive-dvips", - "texlive-helvetic", - "texlive-makeindex", - "texlive-metafont", - "texlive-metapost", - "texlive-palatino", - "texlive-preview", - "texlive-times", - "texlive-zapfchan", - "texlive-zapfding", - ); - - $map{"latexmk"} =3D "texlive-latexmk-bin"; - - # FIXME: add support for installing CJK fonts - # - # I tried hard, but was unable to find a way to install - # "Noto Sans CJK SC" on openSUSE - - check_rpm_missing(\@suse_tex_pkgs, 2) if ($pdf); - check_missing_tex(2) if ($pdf); - check_missing(\%map); - - return if (!$need && !$optional); - printf("You should run:\n") if ($verbose_warn_install); - printf("\n\tsudo zypper install --no-recommends $install\n"); -} - -sub give_mageia_hints() -{ - my %map =3D ( - "python-sphinx" =3D> "python3-sphinx", - "yaml" =3D> "python3-yaml", - "virtualenv" =3D> "python3-virtualenv", - "dot" =3D> "graphviz", - "convert" =3D> "ImageMagick", - "Pod::Usage" =3D> "perl-Pod-Usage", - "xelatex" =3D> "texlive", - "rsvg-convert" =3D> "librsvg2", - ); - - my @tex_pkgs =3D ( - "texlive-fontsextra", - ); - - $map{"latexmk"} =3D "texlive-collection-basic"; - - my $packager_cmd; - my $noto_sans; - if ($system_release =3D~ /OpenMandriva/) { - $packager_cmd =3D "dnf install"; - $noto_sans =3D "noto-sans-cjk-fonts"; - @tex_pkgs =3D ( "texlive-collection-fontsextra" ); - } else { - $packager_cmd =3D "urpmi"; - $noto_sans =3D "google-noto-sans-cjk-ttc-fonts"; - } - - - if ($pdf) { - check_missing_file(["/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regula= r.ttc", - "/usr/share/fonts/TTF/NotoSans-Regular.ttf"], - $noto_sans, 2); - } - - check_rpm_missing(\@tex_pkgs, 2) if ($pdf); - check_missing(\%map); - - return if (!$need && !$optional); - printf("You should run:\n") if ($verbose_warn_install); - printf("\n\tsudo $packager_cmd $install\n"); -} - -sub give_arch_linux_hints() -{ - my %map =3D ( - "yaml" =3D> "python-yaml", - "virtualenv" =3D> "python-virtualenv", - "dot" =3D> "graphviz", - "convert" =3D> "imagemagick", - "xelatex" =3D> "texlive-xetex", - "latexmk" =3D> "texlive-core", - "rsvg-convert" =3D> "extra/librsvg", - ); - - my @archlinux_tex_pkgs =3D ( - "texlive-core", - "texlive-latexextra", - "ttf-dejavu", - ); - check_pacman_missing(\@archlinux_tex_pkgs, 2) if ($pdf); - - if ($pdf) { - check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"], - "noto-fonts-cjk", 2); - } - - check_missing(\%map); - - return if (!$need && !$optional); - printf("You should run:\n") if ($verbose_warn_install); - printf("\n\tsudo pacman -S $install\n"); -} - -sub give_gentoo_hints() -{ - my %map =3D ( - "yaml" =3D> "dev-python/pyyaml", - "virtualenv" =3D> "dev-python/virtualenv", - "dot" =3D> "media-gfx/graphviz", - "convert" =3D> "media-gfx/imagemagick", - "xelatex" =3D> "dev-texlive/texlive-xetex media-fonts/dejavu", - "rsvg-convert" =3D> "gnome-base/librsvg", - ); - - check_missing_file(["/usr/share/fonts/dejavu/DejaVuSans.ttf"], - "media-fonts/dejavu", 2) if ($pdf); - - if ($pdf) { - check_missing_file(["/usr/share/fonts/noto-cjk/NotoSansCJKsc-Regular.otf= ", - "/usr/share/fonts/noto-cjk/NotoSerifCJK-Regular.ttc"], - "media-fonts/noto-cjk", 2); - } - - check_missing(\%map); - - return if (!$need && !$optional); - - printf("You should run:\n") if ($verbose_warn_install); - printf("\n"); - - my $imagemagick =3D "media-gfx/imagemagick svg png"; - my $cairo =3D "media-gfx/graphviz cairo pdf"; - my $portage_imagemagick =3D "/etc/portage/package.use/imagemagick"; - my $portage_cairo =3D "/etc/portage/package.use/graphviz"; - - if (qx(grep imagemagick $portage_imagemagick 2>/dev/null) eq "") { - printf("\tsudo su -c 'echo \"$imagemagick\" > $portage_imagemagick'\n") - } - if (qx(grep graphviz $portage_cairo 2>/dev/null) eq "") { - printf("\tsudo su -c 'echo \"$cairo\" > $portage_cairo'\n"); - } - - printf("\tsudo emerge --ask $install\n"); - -} - -sub check_distros() -{ - # Distro-specific hints - if ($system_release =3D~ /Red Hat Enterprise Linux/) { - give_redhat_hints; - return; - } - if ($system_release =3D~ /CentOS/) { - give_redhat_hints; - return; - } - if ($system_release =3D~ /Scientific Linux/) { - give_redhat_hints; - return; - } - if ($system_release =3D~ /Oracle Linux Server/) { - give_redhat_hints; - return; - } - if ($system_release =3D~ /Fedora/) { - give_redhat_hints; - return; - } - if ($system_release =3D~ /Ubuntu/) { - give_debian_hints; - return; - } - if ($system_release =3D~ /Debian/) { - give_debian_hints; - return; - } - if ($system_release =3D~ /openSUSE/) { - give_opensuse_hints; - return; - } - if ($system_release =3D~ /Mageia/) { - give_mageia_hints; - return; - } - if ($system_release =3D~ /OpenMandriva/) { - give_mageia_hints; - return; - } - if ($system_release =3D~ /Arch Linux/) { - give_arch_linux_hints; - return; - } - if ($system_release =3D~ /Gentoo/) { - give_gentoo_hints; - return; - } - - # - # Fall-back to generic hint code for other distros - # That's far from ideal, specially for LaTeX dependencies. - # - my %map =3D ( - "sphinx-build" =3D> "sphinx" - ); - check_missing_tex(2) if ($pdf); - check_missing(\%map); - print "I don't know distro $system_release.\n"; - print "So, I can't provide you a hint with the install procedure.\n"; - print "There are likely missing dependencies.\n"; -} - -# -# Common dependencies -# - -sub deactivate_help() -{ - printf "\n If you want to exit the virtualenv, you can use:\n"; - printf "\tdeactivate\n"; -} - -sub get_virtenv() -{ - my $ver; - my $min_activate =3D "$ENV{'PWD'}/${virtenv_prefix}${min_version}/bin/act= ivate"; - my @activates =3D glob "$ENV{'PWD'}/${virtenv_prefix}*/bin/activate"; - - @activates =3D sort {$b cmp $a} @activates; - - foreach my $f (@activates) { - next if ($f lt $min_activate); - - my $sphinx_cmd =3D $f; - $sphinx_cmd =3D~ s/activate/sphinx-build/; - next if (! -f $sphinx_cmd); - - my $ver =3D get_sphinx_version($sphinx_cmd); - - if (!$ver) { - $f =3D~ s#/bin/activate##; - print("Warning: virtual environment $f is not working.\nPython version = upgrade? Remove it with:\n\n\trm -rf $f\n\n"); - } - - if ($need_sphinx && ($ver ge $min_version)) { - return ($f, $ver); - } elsif ($ver gt $cur_version) { - return ($f, $ver); - } - } - return ("", ""); -} - -sub recommend_sphinx_upgrade() -{ - my $venv_ver; - - # Avoid running sphinx-builds from venv if $cur_version is good - if ($cur_version && ($cur_version ge $rec_version)) { - $latest_avail_ver =3D $cur_version; - return; - } - - # Get the highest version from sphinx_*/bin/sphinx-build and the - # corresponding command to activate the venv/virtenv - ($activate_cmd, $venv_ver) =3D get_virtenv(); - - # Store the highest version from Sphinx existing virtualenvs - if (($activate_cmd ne "") && ($venv_ver gt $cur_version)) { - $latest_avail_ver =3D $venv_ver; - } else { - $latest_avail_ver =3D $cur_version if ($cur_version); - } - - # As we don't know package version of Sphinx, and there's no - # virtual environments, don't check if upgrades are needed - if (!$virtualenv) { - return if (!$latest_avail_ver); - } - - # Either there are already a virtual env or a new one should be created - $need_pip =3D 1; - - return if (!$latest_avail_ver); - - # Return if the reason is due to an upgrade or not - if ($latest_avail_ver lt $rec_version) { - $rec_sphinx_upgrade =3D 1; - } - - return $latest_avail_ver; -} - -# -# The logic here is complex, as it have to deal with different versions: -# - minimal supported version; -# - minimal PDF version; -# - recommended version. -# It also needs to work fine with both distro's package and venv/virtualenv -sub recommend_sphinx_version($) -{ - my $virtualenv_cmd =3D shift; - - # Version is OK. Nothing to do. - if ($cur_version && ($cur_version ge $rec_version)) { - return; - }; - - if (!$need_sphinx) { - # sphinx-build is present and its version is >=3D $min_version - - #only recommend enabling a newer virtenv version if makes sense. - if ($latest_avail_ver gt $cur_version) { - printf "\nYou may also use the newer Sphinx version $latest_avail_ver w= ith:\n"; - printf "\tdeactivate\n" if ($ENV{'PWD'} =3D~ /${virtenv_prefix}/); - printf "\t. $activate_cmd\n"; - deactivate_help(); - - return; - } - return if ($latest_avail_ver ge $rec_version); - } - - if (!$virtualenv) { - # No sphinx either via package or via virtenv. As we can't - # Compare the versions here, just return, recommending the - # user to install it from the package distro. - return if (!$latest_avail_ver); - - # User doesn't want a virtenv recommendation, but he already - # installed one via virtenv with a newer version. - # So, print commands to enable it - if ($latest_avail_ver gt $cur_version) { - printf "\nYou may also use the Sphinx virtualenv version $latest_avail_= ver with:\n"; - printf "\tdeactivate\n" if ($ENV{'PWD'} =3D~ /${virtenv_prefix}/); - printf "\t. $activate_cmd\n"; - deactivate_help(); - - return; - } - print "\n"; - } else { - $need++ if ($need_sphinx); - } - - # Suggest newer versions if current ones are too old - if ($latest_avail_ver && $latest_avail_ver ge $min_version) { - # If there's a good enough version, ask the user to enable it - if ($latest_avail_ver ge $rec_version) { - printf "\nNeed to activate Sphinx (version $latest_avail_ver) on virtua= lenv with:\n"; - printf "\t. $activate_cmd\n"; - deactivate_help(); - - return; - } - - # Version is above the minimal required one, but may be - # below the recommended one. So, print warnings/notes - - if ($latest_avail_ver lt $rec_version) { - print "Warning: It is recommended at least Sphinx version $rec_version.= \n"; - } - } - - # At this point, either it needs Sphinx or upgrade is recommended, - # both via pip - - if ($rec_sphinx_upgrade) { - if (!$virtualenv) { - print "Instead of install/upgrade Python Sphinx pkg, you could use pip/= pypi with:\n\n"; - } else { - print "To upgrade Sphinx, use:\n\n"; - } - } else { - print "\nSphinx needs to be installed either:\n1) via pip/pypi with:\n\n= "; - } - - $python_cmd =3D find_python_no_venv(); - - printf "\t$virtualenv_cmd $virtenv_dir\n"; - - printf "\t. $virtenv_dir/bin/activate\n"; - printf "\tpip install -r $requirement_file\n"; - deactivate_help(); - - printf "\n2) As a package with:\n"; - - my $old_need =3D $need; - my $old_optional =3D $optional; - %missing =3D (); - $pdf =3D 0; - $optional =3D 0; - $install =3D ""; - $verbose_warn_install =3D 0; - - add_package("python-sphinx", 0); - - check_distros(); - - $need =3D $old_need; - $optional =3D $old_optional; - - printf "\n Please note that Sphinx >=3D 3.0 will currently produce fal= se-positive\n"; - printf " warning when the same name is used for more than one type (fun= ctions,\n"; - printf " structs, enums,...). This is known Sphinx bug. For more detail= s, see:\n"; - printf "\thttps://github.com/sphinx-doc/sphinx/pull/8313\n"; -} - -sub check_needs() -{ - # Check if Sphinx is already accessible from current environment - check_sphinx(); - - if ($system_release) { - print "Detected OS: $system_release.\n"; - } else { - print "Unknown OS\n"; - } - printf "Sphinx version: %s\n\n", $cur_version if ($cur_version); - - # Check python command line, trying first python3 - $python_cmd =3D findprog("python3"); - $python_cmd =3D check_program("python", 0) if (!$python_cmd); - - # Check the type of virtual env, depending on Python version - if ($python_cmd) { - if ($virtualenv) { - my $tmp =3D qx($python_cmd --version 2>&1); - if ($tmp =3D~ m/(\d+\.)(\d+\.)/) { - if ($1 < 3) { - # Fail if it finds python2 (or worse) - die "Python 3 is required to build the kernel docs\n"; - } - if ($1 =3D=3D 3 && $2 < 3) { - # Need Python 3.3 or upper for venv - $need_virtualenv =3D 1; - } - } else { - die "Warning: couldn't identify $python_cmd version!"; - } - } else { - add_package("python-sphinx", 0); - } - } - - my $venv_ver =3D recommend_sphinx_upgrade(); - - my $virtualenv_cmd; - - if ($need_pip) { - # Set virtualenv command line, if python < 3.3 - if ($need_virtualenv) { - $virtualenv_cmd =3D findprog("virtualenv-3"); - $virtualenv_cmd =3D findprog("virtualenv-3.5") if (!$virtualenv_cmd); - if (!$virtualenv_cmd) { - check_program("virtualenv", 0); - $virtualenv_cmd =3D "virtualenv"; - } - } else { - $virtualenv_cmd =3D "$python_cmd -m venv"; - check_python_module("ensurepip", 0); - } - } - - # Check for needed programs/tools - check_perl_module("Pod::Usage", 0); - check_python_module("yaml", 0); - check_program("make", 0); - check_program("gcc", 0); - check_program("dot", 1); - check_program("convert", 1); - - # Extra PDF files - should use 2 for is_optional - check_program("xelatex", 2) if ($pdf); - check_program("rsvg-convert", 2) if ($pdf); - check_program("latexmk", 2) if ($pdf); - - # Do distro-specific checks and output distro-install commands - check_distros(); - - if (!$python_cmd) { - if ($need =3D=3D 1) { - die "Can't build as $need mandatory dependency is missing"; - } elsif ($need) { - die "Can't build as $need mandatory dependencies are missing"; - } - } - - # Check if sphinx-build is called sphinx-build-3 - if ($need_symlink) { - printf "\tsudo ln -sf %s /usr/bin/sphinx-build\n\n", - which("sphinx-build-3"); - } - - recommend_sphinx_version($virtualenv_cmd); - printf "\n"; - - print "All optional dependencies are met.\n" if (!$optional); - - if ($need =3D=3D 1) { - die "Can't build as $need mandatory dependency is missing"; - } elsif ($need) { - die "Can't build as $need mandatory dependencies are missing"; - } - - print "Needed package dependencies are met.\n"; -} - -# -# Main -# - -while (@ARGV) { - my $arg =3D shift(@ARGV); - - if ($arg eq "--no-virtualenv") { - $virtualenv =3D 0; - } elsif ($arg eq "--no-pdf"){ - $pdf =3D 0; - } elsif ($arg eq "--version-check"){ - $version_check =3D 1; - } else { - print "Usage:\n\t$0 <--no-virtualenv> <--no-pdf> <--version-check>\n\n"; - print "Where:\n"; - print "\t--no-virtualenv\t- Recommend installing Sphinx instead of using= a virtualenv\n"; - print "\t--version-check\t- if version is compatible, don't check for mi= ssing dependencies\n"; - print "\t--no-pdf\t- don't check for dependencies required to build PDF = docs\n\n"; - exit -1; - } -} - -# -# Determine the system type. There's no standard unique way that would -# work with all distros with a minimal package install. So, several -# methods are used here. -# -# By default, it will use lsb_release function. If not available, it will -# fail back to reading the known different places where the distro name -# is stored -# - -$system_release =3D qx(lsb_release -d) if which("lsb_release"); -$system_release =3D~ s/Description:\s*// if ($system_release); -$system_release =3D catcheck("/etc/system-release") if !$system_release; -$system_release =3D catcheck("/etc/redhat-release") if !$system_release; -$system_release =3D catcheck("/etc/lsb-release") if !$system_release; -$system_release =3D catcheck("/etc/gentoo-release") if !$system_release; - -# This seems more common than LSB these days -if (!$system_release) { - my %os_var; - if (open IN, "cat /etc/os-release|") { - while () { - if (m/^([\w\d\_]+)=3D\"?([^\"]*)\"?\n/) { - $os_var{$1}=3D$2; - } - } - $system_release =3D $os_var{"NAME"}; - if (defined($os_var{"VERSION_ID"})) { - $system_release .=3D " " . $os_var{"VERSION_ID"} if (defined($os_var{"V= ERSION_ID"})); - } else { - $system_release .=3D " " . $os_var{"VERSION"}; - } - } -} -$system_release =3D catcheck("/etc/issue") if !$system_release; -$system_release =3D~ s/\s+$//; - -check_needs; --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7B2F2F83C0; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=JnoncdWbqggsJ87t2c9Leez5x7LWAyK8uVekH7OHhHFNBEBlILSzGgBNV2FMpARbC3kgiY2po322zPVsDH2u8ZfSHNFtVNUMU5OWphX0VIHyhV38FgVxk7eRDckrgq5HgIfNIFLrNi5Xh+wzjB74KJdhrdDAZEHW8YjRYsuQqWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=WebWcu8z+YevfzDBChtXNRkHwfTSu+wYncOqqxbNMio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tz8WbdB0YQbXhTWTtIIscJHzI//kAl5HYujlfZGuqSaxtk3X3YkPYqGKYGpr4i2ybD+tYyTxmhtIWL4L7uEfycn6lEzM03gJqraa26xEVcN//h8oGMpQq5SXPFy9jp7x1z7cUYhLBjgww+URAwCzobJvMPVM6vN9md+VObvZdfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aSFA8CqG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aSFA8CqG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F90CC2BCF6; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=WebWcu8z+YevfzDBChtXNRkHwfTSu+wYncOqqxbNMio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSFA8CqGgrFaRwZ/HyAv4vh89GoILlu7blWgntOq7dPUcRmI6zeZQwsOt35132bGx 4527Jh27mYQG18NI7HtoFkQ+TM8fFUbsXlO9Xr7ae+Uyobf9+ef3AN8kHiIzuVpKJW /KtNN3SbPOUBiKg27LnbTMXmxNNkh6U1VY9lhMh6O2G1ToXP5ulXvVWbnGp4EuPVGO t8mtIoA17sI+6cK8rpAkeTTrGdihYvtkxFMOgss8VqNUvONP89DTl+51CXZGkDY256 aDPGd+P98uJgt8UrBwB98dW+IIjVpcVPOpGZqZ1F02VFR3jX2ECUfA3fHhEugb/5P3 OeXsltw0frcaw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXX-0Sbg; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , Bill Wendling , Justin Stitt , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 36/39] scripts: sphinx-pre-install: update mandatory system deps Date: Tue, 12 Aug 2025 17:52:53 +0200 Message-ID: <4ec979e4692c9e4acd6c31424c0e2f4bf5b80e71.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" To build docs, gcc is not needed. Also, Kernel can be built nowadays with clang. So, drop it. On the other hand, which is needed. Add a system dependency for it. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install index 7dfe5c2a6cc2..fc9dc45054d7 100755 --- a/scripts/sphinx-pre-install +++ b/scripts/sphinx-pre-install @@ -1476,7 +1476,7 @@ class SphinxDependencyChecker(MissingCheckers): self.check_perl_module("Pod::Usage", DepManager.SYSTEM_MANDATORY) =20 self.check_program("make", DepManager.SYSTEM_MANDATORY) - self.check_program("gcc", DepManager.SYSTEM_MANDATORY) + self.check_program("which", DepManager.SYSTEM_MANDATORY) =20 self.check_program("dot", DepManager.SYSTEM_OPTIONAL) self.check_program("convert", DepManager.SYSTEM_OPTIONAL) --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 971A52F83AE; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=O2bsvkgaYryczlIVyBl2imKjMWmV5kj3LXYAsjgPO560gETVJniZeNZlbKXZ8LysikY9Yphvvwct1QFo3WxlVWOSFAtQTv/FuVdPHpWV1a+0qR/uXVaXk3CHZRmIsurFTb/ilo5cYag1tD4M6owMk0NMVA0M2QE38PZJMRz4EWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=wJnSHEtnfEDAispvO8hkEglJmLys0nv2+O3sl9tpI6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUFB+C7QcwCRftty6nCl1VHYNwyXRK06gV67g4FwxnwriwYGdLrMEF/3b0Pdoe/D5pt95L3EV73z/Gg+MpYhJvudkFOgLtIiNV6HSAXCg6+2rvb/6GD28JmvlMr7dVmn2maKxvPWI0z9P/NQAwXP7g53MV9xlIyvDIrh0b1w8fg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eGzjKHCH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eGzjKHCH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CA11C4AF1D; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=wJnSHEtnfEDAispvO8hkEglJmLys0nv2+O3sl9tpI6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGzjKHCHIXp/dRp23WRPuBOLAyehmHihe4lv5XXB4O4Kb8b+M9CtYz0UZf0hu4dT6 EtTwvJF0cpaQGfA3HJnz/NcpTrgIrpezVU6TEDndJK+iG0o2jtSxwI/A6a5SJalYJo MPFXb5o+880RIz30SQCRlG8jNBZcxKwK+XBiE60z5L5kE7IgEEZk4UbnjywhVFY88v O5Y8DbiE1ZomQGa05Y3/7mgaoxE4VRXYuG6W0fpDG5wPDO47uR8+CFT62SE4Ifraf6 9y1QfkGeir9Gq8VKq7G2sQxjYTkDmBkRT+lqLBHjPi5HZPO0LIbc5vRN+IKTP/1ShC L4bYb0B1hPzQQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXd-0ZNo; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 37/39] scripts: sphinx-pre-install: add support for RHEL8-based distros Date: Tue, 12 Aug 2025 17:52:54 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" On RHEL8, only installing with a venv is supported, as there's no Sphinx package using Python 3.7 or upper. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install index fc9dc45054d7..324baa98a395 100755 --- a/scripts/sphinx-pre-install +++ b/scripts/sphinx-pre-install @@ -691,7 +691,7 @@ class SphinxDependencyChecker(MissingCheckers): =20 super().__init__(args, texlive) =20 - self.need_pip =3D 0 + self.need_pip =3D False self.rec_sphinx_upgrade =3D 0 =20 self.system_release =3D self.get_system_release() @@ -840,9 +840,15 @@ class SphinxDependencyChecker(MissingCheckers): # RHEL 8 uses Python 3.6, which is not compatible with # the build system anymore. Suggest Python 3.11 if rel =3D=3D 8: - self.deps.add_package("python39", DepManager.SYSTEM_MANDAT= ORY) + self.check_program("python3.9", DepManager.SYSTEM_MANDATOR= Y) + progs["python3.9"] =3D "python39" + progs["yaml"] =3D "python39-pyyaml" + self.recommend_python =3D True =20 + # There's no python39-sphinx package. Only pip is supported + self.package_supported =3D False + if not self.distro_msg: self.distro_msg =3D \ "Note: RHEL-based distros typically require extra repo= sitories.\n" \ @@ -915,8 +921,9 @@ class SphinxDependencyChecker(MissingCheckers): # the build system anymore. Suggest Python 3.11 if rel =3D=3D 15: if not self.which(self.python_cmd): + self.check_program("python3.11", DepManager.SYSTEM_MAN= DATORY) + progs["python3.11"] =3D "python311" self.recommend_python =3D True - self.deps.add_package(self.python_cmd, DepManager.SYST= EM_MANDATORY) =20 progs.update({ "python-sphinx": "python311-Sphinx", @@ -1289,7 +1296,7 @@ class SphinxDependencyChecker(MissingCheckers): return self.latest_avail_ver =20 # Either there are already a virtual env or a new one should be cr= eated - self.need_pip =3D 1 + self.need_pip =3D True =20 if not self.latest_avail_ver: return None @@ -1344,10 +1351,11 @@ class SphinxDependencyChecker(MissingCheckers): """ =20 if self.recommend_python: - print("\nPython version is incompatible with doc build.\n" \ - "Please upgrade it and re-run.\n") - return - + cur_ver =3D sys.version_info[:3] + if cur_ver < MIN_PYTHON_VERSION: + print(f"\nPython version {cur_ver} is incompatible with do= c build.\n" \ + "Please upgrade it and re-run.\n") + return =20 # Version is OK. Nothing to do. if self.cur_version !=3D (0, 0, 0) and self.cur_version >=3D RECOM= MENDED_VERSION: @@ -1467,7 +1475,6 @@ class SphinxDependencyChecker(MissingCheckers): if sys.version_info < MIN_PYTHON_VERSION: self.need_pip =3D False print("Warning: python version is not supported.") - else: virtualenv_cmd =3D f"{self.python_cmd} -m venv" self.check_python_module("ensurepip") --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ECC32F83B2; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=DJh+wbiBA64LiQsNqhxkrtwZNjjo2gm6is565O8UJem28CLT6epYNuCpeEWmPpvhv+oWPA1wtP9a8p/RePVzBdqzqn74v/EnkdL4WDX48jfOHLpi2vJlDbquGJHWySB2VimGrIAev/Nu/UAkbRZ1WwG2maFGD5gWvBg//QkvNew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=Ttf2nErBntacD7+Zyv3rczkrnRx+/elXiyJgXiaMhfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r/uYtdb7wjWTIv4AdGVesv33Xknv/IGjPpAnMHQpHmaPqMUYc664k2ofxNRnuvI1/kRHfS8ifiJ8WodPZBwcWIISVe7PI3POgJq+F53z/1I6X88nFIfb0CAbzX4rhGrxO8LA2CVzgdmc2w8RmIolNwN5WqWGIlPbglgfCkyINSA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RIQ/OGUA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RIQ/OGUA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 174D9C2BCF5; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=Ttf2nErBntacD7+Zyv3rczkrnRx+/elXiyJgXiaMhfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RIQ/OGUAkdovMTbFZ76EZtN7MVny+nAhrPOTQF2lWXbCfEhZaoTX58o7RXrDpRpn1 4uB3MvpMFvY2xiFfqabQNH3ncNOWEH7sUf45uViJJJ4Hq19dmlsikRea3CA3fUCfvH DAp8+qezqs1/3r9ZYAQdnw4MWr10z3DYZndXob9UqqqeLQ/9X765eiyBs57ADle4ks 9pJZzg4KhrRLkBnGOU5SX8jfQQIfgLQQtqeC46F0ZOwh3iIJ+fFmO+L2G15hdr0//n YWKMdo26zSNZJ00vqjwBuEMlw+rD/1myExlo+nCVJnsBRAcMwoKRHZRVkXm5bQQzhn BXD0CCP6Oo1lA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXh-0gG6; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 38/39] scripts: sphinx-pre-install: add a warning for Debian-based distros Date: Tue, 12 Aug 2025 17:52:55 +0200 Message-ID: <628d01784e8c24e3d93c69c436f12398e00165b3.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" On Some Debian-based distros, ImageMagick package has a broken policy that causes LaTeX to fail while building docs. Add a note about that. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install index 324baa98a395..09a337509b23 100755 --- a/scripts/sphinx-pre-install +++ b/scripts/sphinx-pre-install @@ -782,6 +782,11 @@ class SphinxDependencyChecker(MissingCheckers): =20 self.check_program("dvipng", DepManager.PDF_MANDATORY) =20 + if not self.distro_msg: + self.distro_msg =3D \ + "Note: ImageMagick is broken on some distros, affecting PD= F output. For more details:\n" \ + "\thttps://askubuntu.com/questions/1158894/imagemagick-sti= ll-broken-using-with-usr-bin-convert" + return self.get_install_progs(progs, "apt-get install") =20 def give_redhat_hints(self): @@ -1193,7 +1198,7 @@ class SphinxDependencyChecker(MissingCheckers): self.distro_msg =3D \ f"I don't know distro {self.system_release}.\n" \ "So, I can't provide you a hint with the install procedure.\n"= \ - "There are likely missing dependencies.\n" + "There are likely missing dependencies." =20 return self.get_install_progs(progs, None) =20 --=20 2.50.1 From nobody Sat Oct 4 20:57:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B6852F83B0; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=Y+nczte71Gm+5l7x+7ygflcmC6aJTEW3OmXXQrFNpztIObqFajh7IueNRM8k61zXwDUQz6DMdHzz3tyR3ZTvW4H1z2wh0Nm+KMoaCjq48Ez/CXAi4Gsydlz3UaSekHfu104I7MRLnOOfTv38Zqob26fA7QQNe+pvsaXn1WCfCek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=i0mHMu7j1L1UYsoNJE+5G4UPEMroTjEGJD+fY6oMYWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T9l5ZhBX/r5DBM3pm+SlJVe5Co1ukmFmTU5ikAYbo5o4gY4uMhqP/0oA8iqDiykb8dY6uIMLiTjxEQML+FtShmnQBNWa2zPMCMrToPPyxbTiJ0OiRhAcguSNg9d8WsV8Q97ES79zbNtWhQswFBhSA8d1J3cHXdmhkkJZNkI5GQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l1JpFD1i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l1JpFD1i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1541DC4AF48; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=i0mHMu7j1L1UYsoNJE+5G4UPEMroTjEGJD+fY6oMYWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l1JpFD1itzwxGC7q+pJ8Cf5X8+RV3TFWbeiYNvZ/umZHmKcsespRuzjY6UBM8T7UY YQRMycqSmiS0n/MlGpf9MnnkoxgRoX+bdnoe12EbfAmg0FEpWVHe7COwdMA+JPwc87 T1mXoTuILmE0cdmprEPYoy0QiVMdbNm07o9TdYfBPVCdJNChzE9fquZEpzBNr+BhID RiGeE0a0FMkYl/eZwMmOA3hi9MUCKUXUp73TjI3PLuZp2UcujPVXuJRtrN4S7eSre0 qX8LgW4uf7YGAE17YDmOU6e6HFcZoBgkaz/WQ+0vByhUMTepyVzL6f8bN62Pc6KS/N qpCm6FpYT9vgA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ9-00000006kXl-0n9X; Tue, 12 Aug 2025 17:53:03 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 39/39] scripts: sphinx-pre-install: some adjustments related to venv Date: Tue, 12 Aug 2025 17:52:56 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" While nothing was really needed for virtualenv to work on most distros, we had an issue with OpenMandriva. While checking for it, it was noticed that there was no check if python-virtualenv was installed. This didn't solve the issues we faced there: at least with the half-broken OpenMandriva Lx 4.0 docker container we used, ensurepip was not available anywhere, causing venv to fail. Add a distro-specific note about that. Note: at least at the time we did our tests, OpenMandriva Lx 4.0 docker was shipped with wrong dnf repositories. Also, there was no repos available for it anymore. So, we had to do some hacks to upgrade to 4.3 before being able to run any tests. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install index 09a337509b23..b8474848df4e 100755 --- a/scripts/sphinx-pre-install +++ b/scripts/sphinx-pre-install @@ -983,6 +983,22 @@ class SphinxDependencyChecker(MissingCheckers): # Tested on OpenMandriva Lx 4.3 progs["convert"] =3D "imagemagick" progs["yaml"] =3D "python-pyyaml" + progs["python-virtualenv"] =3D "python-virtualenv" + progs["python-sphinx"] =3D "python-sphinx" + + self.check_program("python-virtualenv", DepManager.PYTHON_MAND= ATORY) + + # On my tests with openMandriva LX 4.0 docker image, upgraded + # to 4.3, python-virtualenv package is broken: it is missing + # ensurepip. Without it, the alternative would be to run: + # python3 -m venv --without-pip ~/sphinx_latest, but running + # pip there won't install sphinx at venv. + # + # Add a note about that. + + if not self.distro_msg: + self.distro_msg =3D \ + "Note: for venv, ensurepip could be broken, preventing= its install method." =20 else: packager_cmd =3D "urpmi" --=20 2.50.1