From nobody Tue Oct 7 13:07:52 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 2EF382E3371; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=Sk6IJlCzKIf7Z5Q1CNXKHujx07/tr9YB3T/1jwICrzz2v2C1pMArSJnEHqXUKlK19vmdYU28eJv/IDXg+VTI4Bw5pNWroL8HkAy0mTNPj03DjuywVqp78R7gc02wqm9JMoec53NpZ2OUyi+SmuBixXhEeAp+/1xod9X4JBoLrCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=uqL7Npn6nD9bQK26qpQdsjFctfUmYoahBmjchL/UNkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QGSUcnMVj9fZszfLyK5R2DEMFQdsTYnM0szjQr2U6hEzPBb7rsse4OXtumfbGZXoqWgfPyP2Iac0AZtM+cxJfEnIKUga3FafWKe8R/XuT6vlmn06BCQzQ2QS1nmtOy8YrxBDrST9SakkDGZm8yhv2GLUZQXqe+dg1bLMr/Oqy54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TRwI7Y9z; 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="TRwI7Y9z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF46CC4CEF8; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=uqL7Npn6nD9bQK26qpQdsjFctfUmYoahBmjchL/UNkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRwI7Y9z7TFQix1xzuMlCBm5faxFZ+9T0lsEsbsjAdfpRcC1/B5HjjCvNHxQV0XF4 d2T1vvBsjQP0TRq3r55z0OQ4qElJIVKPui16xR/YoHyez68JepExZqVGL5YCcnd2Eq Ywwf1lV7UOHu4Jw6RvYwg6xKWIVSrTC8aCje0OHjvx1GhEoefC3ml1dejU3KCsjm+Y FmY2AFNCiUSsXzGkIemnZUMIirvHKFAkdvno3+hhLbzQN/xPqtN2PTrVFzoyQhtcaY pcTN3BPhKnykQQVI5nmIkIGSlBSStu14OFuvgxJeqsx7LZMAQze3LQogLQ72f7Bwhl j1FohU2BhOxLA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EC9-0iMH; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 01/39] scripts: sphinx-pre-install: fix version check for Fedora Date: Wed, 9 Jul 2025 15:51:33 +0200 Message-ID: <35d114bc75f6044e68dbced77c3a5cfed0da2b43.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 22D322DA779; Wed, 9 Jul 2025 13:52:20 +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=1752069141; cv=none; b=snA5sGm8RIkKvwApS/zlVL5qxGZKB2yXdP6n8vP1h0FzLJvgpdux3aWqLAQdxsF+WIYaX3Q8LOyaA7KfoDnim7jjEohf8m+LZ8qA8+CKmq9kfDzUm8c6qUOB//PmM5F7mqNZTfbJEfI/ZQvW6vwbxORtjLkbfbme5/tlHmbHtXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=+TBUBYTi9gH91LzPyWP0mDdtOQh95p8itcp7aVTzYYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EK43zK4n45x9EH3HLrSmFGrxIPCaWT/LSZuAZfJJV7/7KMbWuR9fnjvCkvVIaDgCuc7zt9A+oiAj6cRFX/edAJfBywgv7uj4PpDxzGQF3KWUA73uFHN9YWIiaAgp7jxDrura2fBW3TsyJI9beA2tW8PsYP6FzwZmsrpboxhMVq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jO/2+0KJ; 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="jO/2+0KJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2DC4C4CEFC; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=+TBUBYTi9gH91LzPyWP0mDdtOQh95p8itcp7aVTzYYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jO/2+0KJO1brlTstJ02pdAyi21A+L/2VLeZVF3Prjqg9uS84p+zSSOt59U7F52A+D HRfbtp8SugvSKrcLKfa3iPwch9HORH7C+KLSSQPVh0e00yT3LSV7bC2ylo0/PDqSPM 6o7sOeSjP4N0XbduNjfWIZY54FF86F85CkRlunYxTOfs159TvMfp9bDVaatv/Q6jDO I4PWWho4cI7YI3GSdeC0ZL6e2jabmyj8POhLbabocqsEfwhicKVE0pxnBfsmEV2gNy X0XPVtM2bt5b2XCvc4Ht1MpFRA6MMPghSE0yI7xWnRQ+JVUFhVxlyfQwdLqlfDCc1Z aEEcYNw2k83ZA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECC-0oPf; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:51:34 +0200 Message-ID: <6547c67c1c951b5f49edb4429f76942af215eddd.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 AF3092E5B2E; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=Xe2/oG6mWWmGqj58zpPPXhh/410CHB5oFslzXUufYGrvYqGYUyUYgvAnRfN2fFoKHwklZ8DbDB3yBGXHlbXubY69K28Izj315JE15Toxo4Vsxa+qojbbjXpfjTp92lk7vkgLFEjKkjSBZKPIS7WrWWQgS65NpUNDIbLjsdtH4No= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=AHUv8NbMxIFwVNB/st+RjoMY9tw/KxAeYaApoBOPh6U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QgIs2EvdRxS38XBDK0iL/CnC2FYuxAfnoprgUmRaRSxLs4ESNRvcjlyM5HHxHiZAurQmTpe3EFGLk1XfE1yQ5W8wsq5e1K/TUsi7x3hICR2sim4lC4HVCv4S6OPWw9/NlpmM+A0N/qqe+1KyyXHSCrvJILNqA1h0i1pg3zXNc9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L5lIHOsY; 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="L5lIHOsY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFE1DC4CEFA; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=AHUv8NbMxIFwVNB/st+RjoMY9tw/KxAeYaApoBOPh6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L5lIHOsYGtbkbH1tUdDys29F81Q0sL3i7c/WjTaCB4hB+h5atf2l9+z7tNj9+DKzz mT3ylJUxTTUVSyRWXNb1JK0d2vIHUrwHhitawaxj1t3vx4SgfD30L9ZBzzbCqvVeGO VYnqBiLn44H2D9Hym4hVOW2xpEgfLOrA7P79jQY0YxsY/tZ07W2h6/hS+BEgMfSAUa i+gmo/oOAlU85QDAcKoPtF/rsRY7TY71rkPiQs2P+0LYlX6r4crp6vRVWs04DXuIJQ 9BRaWRxcrsX/1z+sUWhJcMrO/pfHVYx/wy/uMuBdq0SKx8Vy6ghZCBMssB66a4HYCs OkPbS1jgOKjTQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECF-0tcd; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 03/39] scripts: sphinx-pre-install: Convert script to Python Date: Wed, 9 Jul 2025 15:51:35 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 F3CCB2C3247; Wed, 9 Jul 2025 13:52:20 +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=1752069141; cv=none; b=OKb1SWzdB8GJbmqGEs64Yn1cZeaOefCVF+oKyeHhARnNr9LWNB3vBVGXUVD9O9sxWSKi3tkV33XmLsLjRT6WZt4z6kO9vyOE44nAdcCQNofrdR/7ZBuJ2lDIqfuTQoI2uXD1hWPs1mexRRoqo+fFVstdEfNRmnSg5VOiNxAf2k0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=QZ8qIGEhIaRkTGuQPr4EFUzjS7Cqh7Eui7qNYAGIDWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nUDf/sq/I3/VmeWVdI8kOiTEm4rQwS4U39XvDbnhUwVUJejZ6ICNLZXg3LN2bd1xaD7doIe5yvHLrJ2BhuI+WtvdbbmNMDSnV1AxEENkv0LCscjuQNmQe+OVUETjtqFaajT5F9zX/Y1sTe3ZSRZ86kHckw8eQx5jgyMifFsc5vg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QSegm2pR; 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="QSegm2pR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C7BC4CEF1; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=QZ8qIGEhIaRkTGuQPr4EFUzjS7Cqh7Eui7qNYAGIDWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QSegm2pRG/HBr/JlZJO44ixqZ+wo6FTzjGrLPlRFscaxJVGff3BZ2ZyEccFoLF/pi 0X7tzrTZZP2TPzXdcU7zGCI7mo/jwIbHz13ajFLPyv4Cv0nsQH1gQtYsdIz2wqf/8W 0dnIl8vFYQ8PHy2f4UwI9rIJojP2/4LUP8WETp3CKAYr1fPcu7WO9k0uQiGPwvdQ/e RlATIe8RTSFSvrBtX1YL5z5catcKgHSp5zVYGtEfsUGq5y4Gq0jUuM1vm9am5h7/nz yN29Zw3ncQajmNncxYMaLh5vo57kWXD9IKvL7AYGpVSUol+tAAX0b6KCBSPhs0zXg9 u3o4Eyd67AvQg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECI-0z4V; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:51:36 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 F3D312D59E4; Wed, 9 Jul 2025 13:52:20 +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=1752069141; cv=none; b=eoORsFl/V+1Oh350T7DBtCHRZRD+9hXi1084luubOOcPZrvWJ3adEHyFJEvrukIr+9jE2TdIiIN/YhUwyVHhb+lpAtkY+gtyxEdx3rbZS8gLJWYy8GoWHfzhjWeiTMvL9T3wlYvD4D1iE21yv4HB+d9ByRwQk5FR2dQR9jOxaAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=FoKtf/c/yT5JEXk7gdX1daqHGqUOZCrT4NHefe9FPOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C8D9wwQatzVH0JvNGjJbG7jY1kZuGwfrZXkNXz6xUxwM5RLUSnO49NcjmRSDtbPIBXNIout7SrtRwMxVNmDpW0H86bFZG6tAH3PoEKCiVy+N2iQK89iOzUrpntgbk4Ya9k7EZxinnULh6xSxpovktQjZDjZBcs9e00JFLbfndm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KXJtMjxo; 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="KXJtMjxo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B007C4CEF6; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=FoKtf/c/yT5JEXk7gdX1daqHGqUOZCrT4NHefe9FPOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXJtMjxoETigvjM0rkv6JUeq/6EB6RHT7c7AkcGPMlWVLWkrOlybAGGkltrM27AU+ oAkFCntn5xyInmfiT7PODYPSFLyFH8S6ZT0s6zJzD2Y8TWgHwNCwl4kPz6nIsEMIo0 dWBF/dXaT46GjDKdwUwB7L2sXUz7VtKYXq0hvGV0Shw+YkHmmd+LpEn6HW97pNslVI 32Opx51gzQa+a+inJKHOdQK1gD8JWYBURoAtO89AA5XqApCHUhNPtSwWbvbmv6q2n1 Dd89IcWQz/dMr0e3Ewj6U/d1AwgthsJ2dfR8ZSeNzPDE97Oq5/DvSlxeHsmwMRIbZ6 Q3T4U0q2t2zHA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECL-14G9; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 05/39] scripts: sphinx-pre-install: run on a supported version Date: Wed, 9 Jul 2025 15:51:37 +0200 Message-ID: <31312cbc957e9379fd86d1c58174a407004bc054.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 660652E5419; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=IWT/lmBehPCZB/Ik9tKLP0gLgX65B/OLTQJDgGKWySpI2JxHaccwJUsqd2ublutjcLlE/5aMplwXCPlZoUlbWL6BKXJQhHwas6JhOFj3eMH83gGp6B/5CnGkDadNmCJynYGVFuLgs0gsnIB45I0xz7/YrRQoUBnN3SeqZ11v38I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=1NNB7gvudOACbmFoNoa5MHvLv/Y1IWD4ssO//Nr19dY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oE/bQF3LkOP3ifSC5UbeD5F1j6cYNOH4om7oWiIeJ+Ya7Q2Nzy0VYSHESeb5U1C+9IX62vlm2IPYT+2sIxyeuDTeHxookbpdiN3TrfhPcPnQnsYFUYLm/ItAvT56Ual+e6CSHzgnDTEa2JA6jiunabi940HcWDso8OwXAGW7rdc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mo+SIy/J; 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="mo+SIy/J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B73D6C4CEFB; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=1NNB7gvudOACbmFoNoa5MHvLv/Y1IWD4ssO//Nr19dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mo+SIy/JW9pFpIida6GdXE7DnwVvDLh11HHYo6Fik7SyLLXsf1ubXxVFG84HpFifh c54nLnJ55KP34kodg7BgGJyW1/OgOLfNQzWLwkgYE28vLpUUGmpCVvsWJimUqsR2xQ yj4JWGyMbK5X6iyNPRj9s0kBTO60+jxkvMTTpsN099XAL2K0+g1ECT7EoA8ttAIheC EG/crTNObduUw6idql8zoFj9CEup7yQ3/IFpWC5cdbafOJkN4xGp/kdar0gapn0eah i6W/x37sBSuUNoVoKCj4dp0DWMiFOqvdSxnaeEK/L5KUbmO1xf/eCKYwVxyoDsRJZM BAtZ1euB+GJIA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECO-19WG; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 06/39] scripts: sphinx-pre-install: drop obsolete routines Date: Wed, 9 Jul 2025 15:51:38 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 792652E54AF; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=hUZXU3sTYSJig8oSg0GtYDCbACFZRW+0G3go7X+IgfXmyzzVY3mGzYBCkAcmlx/NScr4LflLsBuzd53KmnjtVWgUs44UmT3J+mR4W9Uiaj5ipJV17o1CuTawzaiMJKVaPLdS6eBhweRJ7ZhwP06dF4tvJSastb3hfNvU5dyx25o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=/jImrr319PEnvqJZTbkdnCbbvj1ZipRv+JMChc+/DL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fVwzKVCJlicDxOjOI7K/niF5WFzsyJmRSGmNRyxNNtPYGVt/ABNehHcqF4i/jqOOgBh0MOuT4W6ElZalxTeqyQukkKoHkMGYWq1Jl4uSmH0aAElXooRE6ojo+//XSgK+gIXK5IQJBTh4HEZ47k4zJztwX+tdG5fs39kVdHBhHSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sTTV7/m9; 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="sTTV7/m9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7150C116C6; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=/jImrr319PEnvqJZTbkdnCbbvj1ZipRv+JMChc+/DL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTTV7/m9IcMkKCpAY5HDGdeanlTqcE7OTFuAsD1Z1wVjv3ziewX07HbT2EHONilHh dzA5AyXHUMcLijcm6HzKtlvyFUrpYBWZYJo7KXKXdgfdRSUQ7mRWkQWMg753dBro0r 2rbhl9m6drE+F8oPTVDQ1aIXtquubwkbLUZ6Kv/JnVINpd9j9/Et9+Gm4lpUnY25Hz igDycT0si6Z7t23AQNb9+gciIu6P/hoN8GNK42QGyuSfwlLYDvytuhOw4Teph9w3r2 cFv7EFYJrbNaIVlTvIq0rpVg7fiV1VUtly++ffxkSocu7YmV9K3+Rx9BMInsP+jtle oczyd7XKPNdzQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECR-1E2e; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 07/39] scripts: sphinx-pre-install: drop support for old virtualenv Date: Wed, 9 Jul 2025 15:51:39 +0200 Message-ID: <2d41a32a842ced85bc8512f3969e5354de556a21.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 AB5BE2E5B2A; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=ThQNfNlXf7b1vqMHoYIxE0Y8Vsn6cgYzF/45epVptpF2JlhKFZqt5tjMcXGUgZ/MaUGMf6WCv+Dw3Gld+ytt/M5B9+rj5FyiewbumAGfGLPDZPQ9Tgfe29WtLGV/olkyRbzHlUeCLYYiMeb109hIG6/Y67jQmiPGCoGjhg9Deao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=Yy7J/4VoJF2hoh3IMFZrdyACnwG/igCZyNXpxhDszW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BlN1LSWrDEJwHsXkJqcaEk1mfSyBBAVhKv+N9klG5TyCKWUYfysD1imfBIbDmQRybYGYmnpLdtI9AZu567VjGDIOpdinCu6dtcBN3IFJxkoRmKdwcvSmRu5lfI9DgCTOVvY7GhRZcjuDkOYFFerkwDetDfwA5wfx1qPli4hQRiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nRxU+ImK; 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="nRxU+ImK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86866C4CEFC; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=Yy7J/4VoJF2hoh3IMFZrdyACnwG/igCZyNXpxhDszW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nRxU+ImKrFr+absNDBcNqu17DM+zVNoh2D/JL4O0p+jVdEkAKOFz5ODt4m5dI8Xnq HhC9iK+BINEHIAThRZpJQRfYDaDpRBTuGigrWyBfMTsj3vSLHyAiNoZQeacp8mHVA3 1pY6BpwGPTfwCzQDsf//yFztLUElvJRHqOHnH7wpFkUraEjOpjl1UIBrVorsTmkdI9 ZirStnyRecZESoHwd1JikUen4ksPst32jxLKjiMk1udw6ev6vv1iL3zRcsKWUScOfR bxod9o3/FNgHOHgqq1EkDQpFR+pMeEvhop+mEOHN5r3PO6zR3OfmQDBBhX5L3UouXC UTrWJiUVMK4ig== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECU-1JGs; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:51:40 +0200 Message-ID: <2d67c2cc005ec27b377bbc2e33e45ca19006ee96.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 D775B2E6136; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=OcygWRLbWXpRfV1AAbKOPCVkgFDBbAWH16BAXzt180eWlcuQ2DQmjDmIJsGtkbWgMYiqFc/Zv4kfVlDlxD1xAZqKHUiP0EVV1lomI9d3xinD4k+LELAjA1UOQ+YcS6ZVdNIB86m3XSqyt6T5mhJiEIfqRstSkPiNyakWB5wfcRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=N7BK29GwfAOZ3YwW51dAhPYfYECxSH+jGCCV1ivhuZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fMF/yh/jG0oxYc22Y4aIscZLqdtjvIPSRO7vWNk3Q9GPBbrGKZ/O30PLrWaur1UWepZc0hutVPaY94LoOX0pQQTweY5srnr+qlr7BtxmyXqT0sk728Uuvuz8dB6RuOZgFzAhZdRu9F4YBcn4cecexEjsg0On4NnoqSqDxQrJdEs= 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+tgUInd; 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+tgUInd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3457C113D0; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=N7BK29GwfAOZ3YwW51dAhPYfYECxSH+jGCCV1ivhuZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+tgUInddmqT6/Nzaoal965lcYUEqITGSERg1bjN6Feoy2hbRvGpS6rNLdvAexkqr pJCNSj91+HpWfaIB7nzjiYgK4zUiOuYBpVXcOqsWrHulmWXbEYqh68WfyA/L94Eqjv /0dnG2f4E2bxUEeQkcAwGzgNYG7rD8QThWIzyNS9O+AfOeA4EAHjbu4aX+pf0IN/0f TsZ0FMK4cO3wguOcaAtc3z7x44tzobR6IZVcj8GcVInfUj1B7FYRkKNRIlVI9cBwet ZDqlr0rq2Dmw5Fwsy9nKedY1Sfg3vyzGlxIZ8+Z6LVkVK8xPENDqfekHtaZNyn3f87 0uKzecDuut8gA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECX-1O7f; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 09/39] scripts: sphinx-pre-install: fix opensuse Leap hint for PyYAML Date: Wed, 9 Jul 2025 15:51:41 +0200 Message-ID: <3ac82fcdf6ea61267615bf85058913ebcdc49238.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 C33B92E6122; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=eQUVFQafYnn+bLDxKiAeDbUXYrNL0zjFtdWetHcJyj7NgZVn9xoCR+5ziNvZJ1slvBfGqYZfrWJUIkU/kRv7Nru4TPo+w9jHueKvZMXbODatMNvVmmtqQyKNn8LqYBtQfW7rD/cxnsCthdEVcWCj1j55hhm2zfKlGczAPgOtkR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=ycz4EO/MkfHKJ8271RLTLGkxXzNhsic8MuWu+lzxdXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L43eBryPTiv8GiBC+6C1jt/frmC+KTMSf1prLGd/xUAzVlIYKq3MkbSciOOFUSgr1Xq4iTl2vnrMn9XlbNoYKUA+qdGtqcHC4jGAehuBIidu+3xdUG8/TrgLPbM99F319DG5C2x/TgeidCljxenu6wwh78lWrMwbMRy2dxe7YtI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QmY8RSh/; 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="QmY8RSh/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FE7DC4AF0B; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=ycz4EO/MkfHKJ8271RLTLGkxXzNhsic8MuWu+lzxdXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QmY8RSh/2ccIcKCxarhNZ7eU+fsna2ok9uthk9M/gGT+5z+eg22I3yBo+pmf5qzZO rDdn+NdGZPDL2mkUsgTTi8E8ypqHpfwI7Gah8l8hucWz+JjMjSSALaMZDbtWPV1p6K yOs3vzCt8NYpj4tmMbQl/Ys4NMrwUn1sqDWq1mjf7G7v+4Uph3TOQ7ZIj+efd0MYaK tdR4tp22rmATFMBK6hQDWeT0RxBQTjkiLV+Yxuzj2gbSRo/aPIUmFppF1d1bBpC/uE ep3ki9jcx4NCvjdQSJ6KxCqFmSXA5tkLFKYRaXP4ki18/IIJy9S3Pcpulw6WH8t3wg sk0spJ9my/jww== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECa-1UQU; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 10/39] scripts: sphinx-pre-install: fix support for gentoo Date: Wed, 9 Jul 2025 15:51:42 +0200 Message-ID: <852f9b2fdf58c32f4dae6e85281e9940a873075b.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 22C6CBE4A; Wed, 9 Jul 2025 13:52:20 +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=1752069141; cv=none; b=ZWisCdQRuWFyS3q9QktFDXD0Mf96DNBHyOArQixWkA8++zHMSeuWqYP4YwXcLI1bCQ7mOCruMibDyHWu+cZ7ftKNIwpWOZaFlrFbZjqKic1GhhfsqClSLLtETyhcHguJ/65G5oKIrVxfHWAu6YZYXHQYiZGol0ULbJgyKN5XnfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=WqD40lDNIRl5QDZ4vfq2ncB8gramfpJAfziS8iPSj9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XAluByWElTMGk3nE/FJFOdeflM8JxjiqGlcM4252opTXlMfLiRC0Nf2tu0S9bI30Ob9502eezv/nEUbOVSUvy984aqb1PPoK+sOD8fp4o99o5E9vkpBKPwNSwy4AsjLNGbe9mANo23lgdJiVaY4Pmdt9/lIgKuW8Xwc9mjPJ6r4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rvML0MAK; 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="rvML0MAK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8F1C4CEF4; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=WqD40lDNIRl5QDZ4vfq2ncB8gramfpJAfziS8iPSj9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rvML0MAKQMQsmQ/lCkHC5ni6MoG4nXfgOmhj21/0NtfRApx5oZIEf55SJGcDuzqgE Rp9ejqibUi6sBoSlMktpfsVqZpTaTG0DGZPMU1lu4mnmGpMKaNOIwTKIkiF9x/gzOK wvshkijZfNYmtWxkriqXXyV7bmwtvOF6Y77w8qLBXrAvT6AkyUYV00bGpVkIXZRSkn IotDzDcrfZnJ1av4vrMBNOJ+j/OAYSNCmvEtXrw7XBCJRdnWeeA2HAkBqfx4DkK5dS xYbFNBGTc6/Lm0K9T4Z3meGIHrEHHmYBw8Fx4WpqhYHRlSeFXW2T3LzjcIWzvhrT8N B6+HEqwOqBsZA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECd-1ZKE; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 11/39] scripts: sphinx-pre-install: Address issues with OpenSUSE Tumbleweed Date: Wed, 9 Jul 2025 15:51:43 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 F3C5128DF1B; Wed, 9 Jul 2025 13:52:20 +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=1752069141; cv=none; b=tZvvq4fO98h94DQf6YlCn5YcbTMLKab8NQ+fjNeqJsv1YyUc7sl06GMTjXUz3hrJtefvJ4w7SQQ7H12oDXEDdi8f6f0e5qt0+35QKu24vXe4vJNCHuZuMIYJBpryR7Wz2GMpOHa9haOzCFSsB8WglOlrhCPhv+yCCtnEOckcHxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=X1fFP6aPpObiMQHIfmC5DpMlMrqUycNg3yqWyp/o7aI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PLAS8yVVIBYXGXKAVtPvBe8eFuG3h6HjCmwgh7nJqiJvM7BJpnCptmIcbx/RyRtbNUDvMqwQa0tqLHxNa7s79T+xHESePBjh83IPttVr/Bbfr+FYRxr5wdsSQiDQwte5+vAmWYQF1wE6dmG84pqMj+nmN97kwKBjCSOlwquvV0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dany8WAX; 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="dany8WAX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0506C4CEF7; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=X1fFP6aPpObiMQHIfmC5DpMlMrqUycNg3yqWyp/o7aI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dany8WAX4ThxgQBYtmW0HWQmklFC+2gcMM8IBApiHFHZUvYtl6W9kPlLoiWX1DdtA D+2p0RY8qIoTj+3o7Ra6birrq45sB8OwAVfVZFA27nqZNtBpWEz/BKYqLu0njGsAgU jzwHVdoQU3X5eHQRKVfFfcqXkXmB7zG9Ih7POD3PNyFDur1U7FfWyR/x+7cRlVlBG4 Jsa42bHuGRz5LLF0eosUGriv4TipGxvPCisvQi+QGfETUZZFTFttcEuiKrwgxpBrRF fpVJF4NqkkgOqsNT0BgxG5plCyWRkCwvbblt2KWOY7XbAHAVXrUy7I5cxahWltf2G8 13nFxXshneHAw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECg-1eWW; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 12/39] scripts: sphinx-pre-install: only show portage hints once Date: Wed, 9 Jul 2025 15:51:44 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 2D70B2E265B; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=Vo3rglxV4Qf3E6UWBVBaOzJ8srDntLHpYAxmm6gtp34BuVlxNx+cVTJLk5d9EsYwXiPYxh79ghSomtS4m/qu1rGy6oYsKk5iibaic/z1V09oM6S4bVfCJuuHPE7041HEA5CvTGcTDKBNhFF4e1wZDpK20xaAi0Y1UbVYNkDNC6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=xFZLNwkdYKL1EU7gu8VeeFOwcLL2l6SYNOrdu6yu8Lg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OKVwCR6XvkOuIeWUMFkFgZ7BWxSD61zNt7bInW8ZP+CXsegoDzuhK28J9ws9l9goULEGQ15BLmx1/2Y+t0KklRSO5IUbEP9zLp+mJBInikvJ4Q8RqAFA7YcelEBEqw5JCjLOrsU3fmBouU8gnj2vdQW0IBrPPERMZF+trOdS7P8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lzgMQhH4; 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="lzgMQhH4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8EC1C4CEFD; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=xFZLNwkdYKL1EU7gu8VeeFOwcLL2l6SYNOrdu6yu8Lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzgMQhH4JoiZn1WOmnEvdnea7AIYUF1l83VRxelysw25y4ouXjVCr59+FwZ9diOW0 JT8yYoxqmhNTBCuehdql+3BLfS0rrhs5wa/kKCdpyy7OeTs1JwWEwiYXe8DDStNXHI EFSeYGzqpbPt5eR3ITZEmsTEcXWTr/u34sfRcVQhbSYstpVcVPiO8Cc6qNkyIWatzt MLm12olIOyGoqT9FLl2aJiVZpOFoHEPSC4cMM3XMiP1f9n6elXkwZDHtJQPzICX2sS rCSfhIcFm3Q/p5VbYy/4LSZu2gjV5Dy49byqWTdO6rf1i+3W70JHSwDEkyXbAhPNpF fOe5FLFbQt0xw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECj-1jQA; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 13/39] scripts: sphinx-pre-install: cleanup rhel support Date: Wed, 9 Jul 2025 15:51:45 +0200 Message-ID: <65ae48c45bf7aada8b90a7bdb8d97bc661ead4f8.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 B8EB02E610F; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=GNc0bQf5+74sy0oeAgpB+Pm/atru50wP64GwsP3Q4zNk9J68Cwr3OGWkID6tArPxnlhGfnP4Xxx43ub8hq4R+A/+peQXIBp2C1JEjScTzs3ZQp/8YHa7YfNP2VFKtijK+7cepIwz4eazb1jj3plfYOAINPGe0KJKxULlojb6dYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=SIQGNNtDKtOVtNJm5iIXTjHrV+UsTcmQyxIm4APuQlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H077uK4RNGRq4ol5xeXH/HMo9BQ2pSVJCpNmtpLpaQXM65NnamlAjjLnC7OowLn6y4Yg9p0P9Eh1pq7c86gpGuMwTyYGeNB6YhQlSykpbATdCbMYawH4jFk+I2RlymqC/szJ4kamAjpxLSwuIdPGCgkLxtoDi5pqobXfBjYBQRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uMp+20Ak; 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="uMp+20Ak" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DC0BC4CEF8; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=SIQGNNtDKtOVtNJm5iIXTjHrV+UsTcmQyxIm4APuQlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMp+20AknU9MieLwiXUWCCqP3t253MruWII0bi690Xd7WJjyQabW+CuJrz+6Pm3nC qqthpByH6uzDo3/37KdDImm129X4Svqrp7fHki49VWXVBNEKk1qGhIP3ZgKKZZEJiK 0gIwLhQKM90FIjdp8Cpp2JTfKE9H6FJx2LvkpiHM4gMpmsVpT6m57R3joDlQXi1Fjq TzSthuTv/8fW6KCIf3eOFJUjfKvnoel4jrF3o9WFdNKeC4ZGzkZW7mdueZ2VfIPg1D RDyMVKbIbcWW8Bq6CWL71rS+oi8ygIvvmDTgeCmVj31gydbHEDcguDFirACwHgDG0t BxVnqQAMp4QdQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECm-1oUy; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 14/39] scripts: sphinx-pre-install: output Python and docutils version Date: Wed, 9 Jul 2025 15:51:46 +0200 Message-ID: <5c041bd36c3a9f86e6d4d3cf98200100cefdaec6.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 7956F2E54B5; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=ROooTBHZtW4h8PmcUUZS86Dbj/Oi3xbnzMQHYGM+iYSK7Czz+fRI8JLduMFj6mNiyOOVKfz9K4TxgIOd0E/iaK9w0uIYFp+ByiuhNDePfTuGjSChYPjUnfeJdtT7Hwmx5UOYy705kieyU4TTayCv2PXtnP4XGtSXtxn3XlCm+9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=9Jx/W99p/t5XFLDw498BHo4ed17hE2P+Zs79xhnHe/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XBcS1c6m9hsXwJF9aP6oQ0VlvjXSFt5fiJcUCTedjrkJu/Oul3L87KF3P76buBkV4r2CgbJFX9s9P3wC/6+eTnRRAwQj6CCOz/YWlJD9yv5FOAZ4XrWZwURdKsRnSfaM505HBe7NSSyGgDPwqi/RZ8Y3YxZuNX/dmMXnVAUAoKQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YoMPIdfx; 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="YoMPIdfx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCE86C4CEFE; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=9Jx/W99p/t5XFLDw498BHo4ed17hE2P+Zs79xhnHe/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YoMPIdfx6CCVfaSvAEwo09TJsNDCb4mMCkwAfUh1b4IkyoBI1VKYrYfa8hJvEkouQ Ga7ZTCHZ0amlWcWxjzpDprmjILYs9hpcNya7fq69bntPk4n8oDgP+YREZOkeViYNZs feOzCM3S0hWxkXVsj5T/mSkvZ9RXHo27oO7z4t9kEzy7qZB0ap5TU37V+XRKzckrUF auOyY+xxgiKvNqG+z+6Waafml32KocnokUh2IdOryiz2Jb7JbviM7sbQtL2rKRMEdz NznN3OFD0X5jrzAfXJpl9H0vJc7X/3/mCj1KTdyMVIeI+G+HwvHN8fK5X3ngaZVpyT z2XijSdHaufnw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECp-1tpT; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 15/39] scripts: sphinx-pre-install: add a missing f-string marker Date: Wed, 9 Jul 2025 15:51:47 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 794762E54B3; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=bZ/VQbbqFs0v9NbQECiCL0JTLTu317LknK5wvPvbqPCrBYqrYAGaXOOET0mDoY4RVktMYKGqXzsntTYARbnk3L/DTHLjcdHy8asJ/FA+R3LjxgOcRtK77i2pZ2lBBznxVjansCtkofImflTTi2YXmZTdQz6fOkT2lExDbQVh3/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=b6fptr6JRQPFlN7HHjnH+rvHZDs6wo06AtQN59akfOI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a6+DwpABf44PDkkFCZs7qEPxPqZ/bK8K+WRu2NKY5PnFcnEnFgcJTEPIcRUiSv8BQGRNJO9BlDgUnYzH9bw1QglPr2l1LFvucZy8ngI+31Eh3EWO6UKW1TxP61ml/XSLbXnydZjtkrIt8zQCmuZXzCdVobEIwGmK8jDcToAw/Ew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gUkMIWnR; 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="gUkMIWnR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2F0AC113D0; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069140; bh=b6fptr6JRQPFlN7HHjnH+rvHZDs6wo06AtQN59akfOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gUkMIWnR4ta5OCgwKvQrOtWNhlILJuTYeiEm3w1wukUKsr8lOzp/TIlFJFyaP93RW w7rg1IymZI5lgvzFORah/oGKdlfNWF1A4G+milvUtnO7FEa0CtCR9KFSorupnLJC2F 2/1TTkQOKqbtrE6rKo0eub9884BTCBPnoq2NaF8qHUjK/0z31wyZ9VM5ZAlxsj08EF G3MsZb7s+SU/OKjF0cqZvq/ezjJvvDKK4u088Pa93v+St/HaTwrUatAlzSQSGncf1s 2OCAW0r6UO8cGXprNAJRTVCNUzvncW2BJJD6ES4+J9TRiRI5+kgzJVJ2mmo1bB4yWY 1qZEKSMonrLzg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECs-1zW2; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 16/39] scripts: sphinx-pre-install: fix Leap support for rsvg-convert Date: Wed, 9 Jul 2025 15:51:48 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 E17C42E62B0; Wed, 9 Jul 2025 13:52:21 +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=1752069142; cv=none; b=s6y+wTcvbIMXZtu8EPCUYZ5PytlMHUDKBJJwFOSCa3U+tHUAi+AL06DVmgImc4MUmSDTHlGytySWKtYl1x6jThHZtcjpB6LMWWJPrZiAUIdyKkxapqnm75Xw1cu19ZswjgfbsUOR23/Ozmx2F7lSuBk7tOyADSIjSL2tV6+5qaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=nMmas0XFZGSWcl0WU6+OSdCq5sNHfGhO+wgD68EYMNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qlnwf0IdDoymAn7qzejRtzwDrb0ShRR5rxQCOV8O4cOpDPaAj0l4MtCutYJJDXVcvT4a6MYe5VxDUjx7v2BzAvV5+vsBV+o9KaA0W+iH49X4i4p01chpVRyd72ozmUD9YWKqB7syhxM6p3OadMwpJlohMtKdGRGYN6P73Sztw3E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qCbGNnc4; 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="qCbGNnc4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1921C4CEF4; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=nMmas0XFZGSWcl0WU6+OSdCq5sNHfGhO+wgD68EYMNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCbGNnc4eHBiS4icjvDcah+C+/9cgh3OtNzY7hidLuBellcf1x8gqx1ZGuos0xI0B tSxmu6lUCtZbH0SHQSDjUmA8LKNqQc0ifZ/9JIK/nr8AeqiPwc19lmGh2eBdELW/cr LvpAMrPoz1b21/3G9vMqZE8QxttgGKbLr8tuCd3072PM/gkDzy46QUzIRXh4SyCxf5 7W+D717Eg5be3vb47W7ZfWAgyZDc+1c04MeNVh6ZerTh7vQtyLdy8jFHvvK0fdtHnf GtOXpAzCV+xkowyN/Guy6ZmeGbe6PsbIUFEs89PlKuPVxqcnDjvL8u4wJ1Wp7SIfTC yTxRh14VoRAew== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECv-23tV; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 17/39] scripts: sphinx-pre-install: fix rhel recomendations Date: Wed, 9 Jul 2025 15:51:49 +0200 Message-ID: <0329c315b356c1b258dabdc889c1c88b716dcbad.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 C10272E6121; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=T4KSs/EcVRHRhZSSM/VOLU3KpD+7I/2LjEcgrODNhKwFuCOKoiU5xLDvouEShtqTiB3MVjAUmuAmBcM6l8q+BlJeaVSSfc+0G71P8GA3xkP/CJQciA/ewQkI0JIvZ3mONtsSwnE63Dz33V8Qc23Ain3RM7HJtrUIMUtbOdLjm0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=YayXrWU4dgHM/g5FisQRZpECv8bW1QpCFl2U0h/pm6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SlJJsHcErZxzcxhEccXzoX67DbY2pBLHlxD2180OnmAa5lOJ1AD/wu0wpk+asa1hZ7WVaNyXNMXFslmEiVX/v2P/yLhjhrkzMyR0t5kDeZxEtBk5U0CFHjzFS5xecJE7NLWOOs0xsxJW1wtPtsTzUTkwmuvVHMOMVgn0cwSrYlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M3k8Mo7k; 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="M3k8Mo7k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95091C4AF11; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=YayXrWU4dgHM/g5FisQRZpECv8bW1QpCFl2U0h/pm6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M3k8Mo7kqN27YxdZ/tuY0H9VSU+iH36Q/VlT2ibgoj2lzwQxLBctI8xVtuWrzzxx9 i4bY3Q49Z72Z1kz2cnWX+newzgaXC2s1BznMOxCY/gT9TIwdB+r7gjlue8Iasvvh12 yN53ivuy4Gw5lolGJj1Sv2GEH1AnxS38gLmFQeEcPlTZ/S/WarLrI6mtjaWkg+sBBs VENKzbbqB2X3CuqCQIByjrwCkvc98FydCys2AySaBRez9jZ4G/iJrU/ifeCAA615r7 WECLDIKP1eusMat/TzzmCfqUuJ30vJnzfKGMrbVq6gv/DMVB0Y5iG+TIUEl3ay7H3E RNRibi23D2F1g== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ECy-29Bh; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 18/39] scripts: sphinx-pre-install: remove Scientific Linux Date: Wed, 9 Jul 2025 15:51:50 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 D5F332E6135; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=jkDuDovTpOeqqZBFr8fExHOyGQpsxL8eNaXiFNjvz56wCBmKEo7SB7wEpgMcFV96vW0saP4UjbcCbJRMbLs5K1fCw97ZRkfaCETM798KsmPEDywoG302EpJbE62vZSrHij3TCWiDxAlAz/Bjb+S0JrMGtBqT9zJAIpg/6x3aWk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=coaR5Sph2qr70HI6P7zzhT6A3liWbym2RGbAoiUCuwk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ftsxATWgnj614AWOK4heOl9SExK/xiMu/RWY3UcdFRIUJIyln6FB0J+b46dr7G9sO55zIQcNQdlGdY+DdEsKp9Fkczm6/kNfTYsZ+c1CLLhMQzaV5W9kCn4ySDC4TxL82wa22OuZorLlHTN9z21Vl/tq/jtc1c2kjbg/bQvh5UQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ANpv1uxW; 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="ANpv1uxW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 780CDC4CEFD; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=coaR5Sph2qr70HI6P7zzhT6A3liWbym2RGbAoiUCuwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANpv1uxWWTSc8CMMwmcBBEJ69A1ibI8R7bxfENDTGbdj5L88Tw+cuDkPOyc3ksFz1 TsAsJ6L9q3CL77BAMik/f2RVhEQgGlZLP9fp7sg41mrlInpDbvcXZw08TrFkf5DtfD L4ce1gW0FQykrA3rzJeO/9lmy9B1jUO5d2NYvaYlIj7CVOqC9ExCioUqK21h/D0Rx0 jUKRrzmNf1jQOgAQj5Kexyi9au1IPqPiZNfRxbwYAZ5W/gmEgHZR5YB794cUIP+A3U ze7Sy/jSy/EP0ALKZ4uI4HGSL5tiNdjq+SQdZ25UXAcSvxWygV/8rgIdAmJCYOtSTl 6TiwvdgeudztA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ED1-2EB3; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 19/39] scripts: sphinx-pre-install: improve Gentoo package deps logic Date: Wed, 9 Jul 2025 15:51:51 +0200 Message-ID: <424781c12a0f08f3b0e6e707b0aa140acac5e742.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 D19502E612B; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=dPKiEt982GqLVv4g8QidcM8oGca3GZAEBOOdpL/ofLFE7FKGYTqqemAUQ9r3Z48g1lopllooNizdTcm2hn46mHafI5OXqpax4t7B/nExqUmbxbPUuvWY/lXHhmeM1/jQ4nJjDOjVfZHLLXVCePQf42A06CaO2jTiFVcuCMonDsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=Yq6EQQuaN4uyi7M6IJVol8n/5VTCTfqJHIGuz9Qu2Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q5tcPhj5fBzTXQHKqYbUIzHodEp8Ibt0FXM/7Kp7FiSaffD43akQU4ZaGW5K6lDpHbqwqwOMdtsgldQnFw5feaOtQqCBCi/8EMNE2lA/czJr7VPSsQSqGEFSNcDk227BTp3n14v5IgE8GgypLgJLIXhVoZw+/baQv4fhlQpylfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bMZe2CSJ; 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="bMZe2CSJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A09FAC4CEFE; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=Yq6EQQuaN4uyi7M6IJVol8n/5VTCTfqJHIGuz9Qu2Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bMZe2CSJp1G+a9eDrkp95HPxogcv5N0FH2aEtD9wGdQX9HMwI+GEH3WioWun/Yyvs BlZ89fNZ9prand5YpoXHliZU2d8SYHnHmrRYCbg5jD6FGT0ND/LgW8hk8CAZ12HSAB fwA2iRXpOdvXueDwM/IoBMJUNOjr96h/jro4Mw9Ap4prk6apzZz3wFvC+tA6k068U0 HZxvSQRqmAqe9OfnPttRRJM/mdG2JsYZDaT9drIknUXtYIT6ueZHDl36Fn74CAwYMU JYuv4DLHLjNRmDHa7MUVbnSIXQyv2AN+0rl6slacp2y8YYexO2YYw1Xyw9E0eoQZsR GsnWgwYN/FbDw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ED4-2Jam; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 20/39] scripts: sphinx-pre-install: fix OpenMandriva support Date: Wed, 9 Jul 2025 15:51:52 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 F2E432E62D3; Wed, 9 Jul 2025 13:52:21 +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=1752069142; cv=none; b=F03xLaX7zdUYiLJ+KYyZiHVazRVBEKP+5TM5xc/uVkQA9l5uPyJiu4ZnrA/gpH/ZUZgkHWl53yqT7LpzwWPNdo/0uI9XJfFQAQnBIG6N7iDTM6YFXNL9xWKG0w+3XJX+qQ/aDYiDhtoabBmB93rEnMrzpnltpfMASaFbheqL+g8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=ki5wlJa+Ive/qv1Artc7D8D1XJBHfhfyZzJdUIy50F4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MbGcOGMZN/FMiEDXHgHmp7CoDmL4v3ZHIL8KYzkVbCx4ES1FJ/uBvB4NXvw0jlRigso/pBCnIPqmwd6xsGn3rn1IjK244j02z2tAHoyj1OQ1eRxKqQH7uCK2vjbf+8001H1GvJnlI/kKMSMh0Xr4erPzC+9AiUuqZ3C9+wDUiHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jr3TdxNU; 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="Jr3TdxNU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE68BC2BC9E; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=ki5wlJa+Ive/qv1Artc7D8D1XJBHfhfyZzJdUIy50F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jr3TdxNUPxwDQ0+KAn7MxHZo6eaufpyFTWDuzre1fsTcUiWOgDf6imsmwM2oPfpFc e8re19FLOG4ULbZEDupkuWS5tsCyg2uHmDDMYKO9PWYYvw8XNIbJ3/T2+7Cnfu5Nyz k4vEDOh5hKTc+Zh48pQFqpnHrFYB+mua1kNSCO2QbXzWJSEk6NYlYUi06JcRPFiuBc RIqIIRhuCqco1O8ycuMMFjOziAX6JjiKYUWe5VN7kpNNB4Q7N/+xy4KD07vmLgDCif Rb8GSEiUMkJp9WcCq3jBT+LYRZg/nGoYZOpMbHaW2RUos18gOulDhuDd0uuJu4J13o RMcYlN4RPdL9A== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000ED7-2Ol3; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:51:53 +0200 Message-ID: <243a2d17dcbf262fb5eff8d66cdb78be35bd1aca.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 D248D2E6131; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=YRiX0YMfn5QMuXogT0uvVZjq6ZPqeYpt9yP1HCwS6EJ6iigpWfCtO2FikKp3XS+bI/RiMKarGgZx455x7NkY2to3aUDYI56MyQv31OGe7n7mOx2aIihPCG2Cs+2LTW6R30qGTyMaZ1vHG0aT8RhJnB8MelMZjJCzZN7qZUBRm6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=g9ChELiDAoUSi7gu90s1ywGkvYH8DY5gFmnDVs5kcKs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uh9yBqENX5wDg/LL119ngLlFa5IllOA35mC3tjxtitUdWXBMiN54GvFJXuQqaMaxtAi4wLKq3eTdWiKmCnIkmUNpjPKt5XM+0RbuPKG1KWbxo9gFbLXTCyPn3Dk+CN8KTDyFRtz0dnjcob3Dk1tkKsLvfqYyj4x5hE7Nfi3di5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fT7LQyYE; 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="fT7LQyYE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0E7BC113CF; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=g9ChELiDAoUSi7gu90s1ywGkvYH8DY5gFmnDVs5kcKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fT7LQyYEnPz/6q4knFoSkUzv60kkEAU1K8mBYsHp1jBJCyWje8PEsR3mrq5XW9Eji NWcTxt4CvXs6WDnMuRbLaY1IxfpqWB/EvZtABM/ihJznMdvg42iTBFdCqdvKx3+c2K Gi3bAtfofj4f8jrgKDWLD1ptK/Lp5R5QgYzU6y/jdPXfRdUn1VJ8vs6OR4NyXijVpG +SnNeNB6CI9XslNOwBWrrfCILtOqaDCobmQykWlzlqhFydEL+41N9jjaQB6Wj3wA1e d+HtTfzz0+TI64kDn4O4rz0p8o8UqscsYvWCO/lkAD42DnJnSLUrP2T5LdFyig1F3N IVjXysDzM2Sow== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDA-2Thx; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 22/39] scripts: sphinx-pre-install: adjust a warning message Date: Wed, 9 Jul 2025 15:51:54 +0200 Message-ID: <38e2b4db70c105f24500507b07ec9ad515924538.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 B8D912E610C; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=F4in5NAbb0C4nV1RKJ8CKOVU3MtYiM+5KCsoXIvbkCh/4AJ8fZhF4DcU4oI5XloY4G8ootF4litht1raQwbx+YUul8QuFdYOIbyZO48jcRJvJs/vh2wOvvJtrTAHzWm6wWeMVnqA1mbLbQJWZ51vFtXa4jTaBQ31fqD3LI68iXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=dlvtFjDx3u9j2myWhO/mqck+5Tif4fxNwbNfKRZqDdY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fzk6u6fyN3xfmbdlDbX+9Zoht4W5nZRnvq0JJmaevfgfDP8aPflQ5FthBWyFGMeQj0FsHDruekZDw/+KpPZnL931SYdxCyKimL3Y3tG/7QALGNXu9J2r4XNwS9xoOvAU81j8tAJCX66T9ygy3hKJj8LpF1LCq9c1hzYBV4lkAwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fq1GDBVk; 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="fq1GDBVk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BAF0C4AF09; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=dlvtFjDx3u9j2myWhO/mqck+5Tif4fxNwbNfKRZqDdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fq1GDBVklavfrdvDCoKzxDKA5ISVbqdrt2kq+0CpFvbO73kVK+kDUsr7oXnExm2Mw b+PIWqKqlEvIkPd1LVO0OC2/cp/NinIlh9C8KM3VHTQdHvIdvtWZwEgo/jFMhtyABO I18edLua34vwuftyPrU78S9uRs2zYsjhGoigP/AacH38Tq06lgQjSszL8EYWuVL5QA gmGfP4IgTVUc2tfMRZjlX1YTNMUQKayBwbOVxRTSfIJdq5m9ey+NH90msYScykTXKm R4jM2kW3Yr0+gfOhASrhridY/bVJSz9YcE6lfy8L5DUdKshroQ9CEty1EQwV3BYGfr QIGXsZb9qH8DA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDD-2YsP; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 23/39] scripts: sphinx-pre-install: better handle Python min version Date: Wed, 9 Jul 2025 15:51:55 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 54D7B2E7177; Wed, 9 Jul 2025 13:52:22 +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=1752069142; cv=none; b=b9yofZQ3Z0WTo3ZGiqQK8zhTsekkfwzYrrAosDp/8q1TdtvxapdmuGn2Tc6WDw3rCzAFq2lrrgYEGcQ0NhhK8NDE/CwxQZHhGv1DbnPvlU1SpI13cIQ1XQJ99b1IGp14LN6K1eyY5/NUS8pfalH6BRu2b5BCu1oxboSFESiBbwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=Lb/swLtGUBLG9dhOwLjNirOq60YQwIykYqGM9+QNXCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u7TXU1GzYW0zJNfYXu6W8YS+cKhebJ59SnFPv7jTH4+pZkXSE/NIlxgb/3/pvtOphmhBPO5nG4d87mbsPkav+Qt2C/16vbOgZjCbJ1pVFfQZxiyIopQUzewauHoGZ3pKw4JWOUkjlSYO42gFsxJ4oXd4sPHlVBlGjGTzmjTY45g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W6N1llrc; 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="W6N1llrc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4001C2BC87; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069142; bh=Lb/swLtGUBLG9dhOwLjNirOq60YQwIykYqGM9+QNXCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6N1llrc0K4NqKc9MGpXhHUIeSxRSTaU3g5DpL4BPwQKO690KwqTl0IDPqFbreX3r uRpGMmGDS1otbgvukJCSOPZ4g7yVM1qfbT7uIWOUiVZ+YOJjbCTJtB2jy5o0+flEDf FqAugLtsw0zEX8aieyRFUu9NF9wgqQ2inkmfj0dc4v3I1oSGPHPH514K+TF3A7BVde HeNfg/NIrdspGc4QptOUdAnZ49t4v2wF9yOUdKqKwIqC7Dj+Z/Pu0R7jp/7goxPmJ6 CEquu2TTLtjccTl8q6hvlhPpZ/zWTYWHvl56NNZfHpQNUPC+V1IzdTjixh/IZxPnTQ wJw8LOL90OiFg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDG-2e1D; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 24/39] scripts: sphinx-pre-install: convert is_optional to a class Date: Wed, 9 Jul 2025 15:51:56 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 EC7A12E62C7; Wed, 9 Jul 2025 13:52:21 +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=1752069142; cv=none; b=Xby6PnP/zIMlESRQQ1Qvtcd/CfyDmBY0aCXES/lNT8YUbNxGBIDj0UCcqhM3t+CjZeTnRU2dc9AjEZRi2DiV41ECfb+2yvwYqLNarRJD895hG361HElycjDr1tHdsI6OOCAfhnAIxYwbr+rBStXLyzlQsmBWEDm3iYNlT3D5EmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=FBElmqvyhBKLXVXL/Ckav/ng29pt1hj+3FlkcjHKvNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sYLLdwGfOMU9iqLldrnLLwYTzdJM3yimCJKzidhW8z74neQY4LaOJmBy/M+aae6x3eSdBy8/xH8rFK3aE+ZrkDbHFhDvpGFqSuU3BBvlFYeEVBYTEk4zHPOC0UY6mC4X82YCL9RcLBJ+qIXwV6NwT12rNBAV4O86BqzfjxAovPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cp6CdJ19; 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="cp6CdJ19" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9094C4AF15; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=FBElmqvyhBKLXVXL/Ckav/ng29pt1hj+3FlkcjHKvNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cp6CdJ19RKlmasF6xihFNkVJUQuy66Dk7DJ05C1fEUgTE35cyyybr0FvQDVnzR7H8 yKoFHGWtpWLBzqTGH8LjHmKmEq/6aOlszO07I6KwnkjmEpQKxlq/WmsddsG+zuFD3S b4+kZeG+TaIlfNHvrQ6d5syb1EEYLdOFTKQIBEnDyoZcPQkSAoXmDqKalCGx2BD3uC S4E8oCPTyHDUaLDR88TURREqk8PpHQCg6H0K3wv5hEzMMiYk9YfcLMiJjA+yvN+qEW BFZh9jITUYnAJoBQV+z8ksBNtSIS5sfRdmLVdM0mtKGKURPs5BH/gFpDtimrHg5aOP lNXf8tSkw7qrw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDJ-2jGo; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 25/39] scripts: sphinx-pre-install: better handle RHEL-based distros Date: Wed, 9 Jul 2025 15:51:57 +0200 Message-ID: <96c4982d419b60af948e1b4d9b44a51a2681abd3.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 52B7A2E7174; Wed, 9 Jul 2025 13:52:22 +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=1752069142; cv=none; b=JiOhKv5z+FzPNEHPs5mZi4AhGTaLuqZTKSzIZb30oB363tFzi/tlRG+N5OC6sco1YwI8HpjTrwWDQ9R3X7aV1C2lGYI0IJJ5xeB322Z+4CzfiVdN1qZIuR25muln9HSnCmPPREVSqj9SBLLEeATXw+amZb6vMSkHZaLSSU4iIYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=RueffcvRIDBMi87r9z1UtD/9fAlr6jNpZ48zD4mdxEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=btXqD9fAz/15uH/kXHJFtLt1tS0nol+LmjGwdj0ZpY988/Al5HXODx5pLWTEXkVCSR1mQwvmGImpmDRnHhlAiIsQtuGYR4O+RCT3YnezL/qX2+x8c7M++qkLOAqLMSc+9vxkuxSjhKNyId2BDAxQ5gba7GzzzTuQXpoyzFR0Iq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Os5ODMwm; 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="Os5ODMwm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE659C2BCAF; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069142; bh=RueffcvRIDBMi87r9z1UtD/9fAlr6jNpZ48zD4mdxEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Os5ODMwmRMfr1p9vKuQy8CQir2xKw3QFxr8Uzjkc465O5171W3mLLREHt2U1towi4 qooZjWT5BMgqaKp1+aBmfFS4balt+ljGSx3XyAOmtUlr8hR/xBiYZBBAOsbVBfq+Xu dW2sgeWoBLSWqVMVVLZ7bPQLJ9+M9tEwrjfmQ69qDzV7NNAtqZF/5dIMH2N9ytx7NZ A6b5tHge5xw11uhNZ5u2UIOCpqlxL4f58qhaBpf/pqLzDWeYYgdZyM9zYnRfh7x+bm emtKv3ha3oZXRtFYJxPC3WOJPOZgXKxFVh7YAlmmsQ1gWI+mMACCjtIAyvijK0vSuw a1mfbmEdT6WBQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDM-2pom; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:51:58 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 0B0202E6D08; Wed, 9 Jul 2025 13:52:22 +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=1752069142; cv=none; b=ZnpUolnOqjcWhTZA8quoHIBOTYYHd8lkPUch+nv7ruR8e7Pd7dNOHOGAqPWPGmgQvKJZkankYRZmnBlKTRQGeIDTqkqll38NMmbvs4JiBX+jhivSke+5rrRxSbWnr4Z2aDgzWaUV0MdoudPDrYASE6WyYPAOC12Wm/xTVVZh5BQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=QTYVPi5+QHYNlWAjLlwESsHYWhntymHRulFXntyK2Ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WeMSlRF+HrGN7WZTSxpMWzuo5jhZnA9yr2AGbI2Xexh+Gz+4iuXguhq722TG1umh7lJiZJEndPqS7wf7Ke8QcVk7kq4594MkqwjuVb+yNDjUe4Zm/o2C3oK9ZsEU+l9cCHF5DoZdrQ1EOgfhjLPjRixlFtA840ciBWR7Rnj4e6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j612QRsW; 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="j612QRsW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCBA5C4CEF8; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=QTYVPi5+QHYNlWAjLlwESsHYWhntymHRulFXntyK2Ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j612QRsWx48p2RmEwVw4V78JHpb7j1E5lUslmENJznu/IINFtAsBrLyu6jcYECrf2 MEumM0KFPc43kxIVTi8DLn8476dzHluDF/j9vTUPBtGWROLYgLF43XQdg9BaCwBjnD fw7Hd7A8edE6/g+n6wfAva7JqJ6VEcf3YXRxp2eh5gwVdTcNiyeUgmm4BWtE3AL6dY qFFnOENBJyaV0z3kbSYjvQhKhF2+GAjwo99RvQkX6oD42l64kAhyfkHmdsLxSNadWT guN0nxTLARrmlC+cxYT8dY1yHRkXnigzPRity+n/lIGq4p/Aoyq1yjbCC5XKT80686 kFfzsUsyTjz6w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDP-2uMQ; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:51:59 +0200 Message-ID: <335809ee3f373a2f4193be259c3f0bf769f4c0b9.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 889862E5B08; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=UuB483cqZjqP104Vv70DqdEhpf6jkAddubQHCal4TVViqGruI8Flyp6fvAvWSKvca/7PEht/BmFPQyXGFzpMmFLUxcWBKnBHj33mZmposTf378FSQmfJZYDIxJzr+VubHNwhH5h4cWusoUypTaLED/F0QveOn72y3bl18jqTCzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=cFBLDKNOa0cAvpqcz75eL+YkNUnkHhNOQfpoyeRf6Hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oDKvicaEHJRVE0a8gWt3QNxOhvUPsnH7sO16PVNfsEneFoyrOErkK0Z8yTpajsMMAjKNiX5fsnJW4BPzBhiJfHNFdJGiKeCIazenSkh19uXuMhStsnFDFikC/FGhFxe9e1+c8JvSCF9yi/VkK5EgK8VPNa6BryzhbX98WdCdsmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TPliMzAf; 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="TPliMzAf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4377C4AF10; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=cFBLDKNOa0cAvpqcz75eL+YkNUnkHhNOQfpoyeRf6Hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPliMzAf3njyuzZfLwW05Ceh/4IgNefqHpq5AsO/WIyROwZu92xeSsohvsvmiNeLZ PQJUc6eYGMspbz23cSf0dI0IKkGOSs1rRfXNk1cw7qf/2inVbTOq/Wv1oRnoECkDgk QdJXdQb+BPBScMTT9YR7OyBFtrCq8OSbOidyawMc875gSU1fvcOvKzs6e4rgCjdsaO r7dSwXJbp2SwPqBfgvTgrhKYo82EkM/MiYtqYwvNXchIBc399iJ27g7X08DkARXp81 +zl5auA4092lmLeVkdStd4tx864piV7stVGPogA/1tCy+hkllhBpJG1UeQz9BUkDJx 1FeXyjemo/svg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDS-307S; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , 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: Wed, 9 Jul 2025 15:52:00 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 0B13D2E6D0A; Wed, 9 Jul 2025 13:52:22 +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=1752069142; cv=none; b=JvN4b3LoAZ3/4yzF5v51114W2li8aFeiDVYVi7TnIe2TMtajY0QcVwIMq+kB45TcdHiWmIbWpYSshc6+WtWbLMjTMYdFFLoIjaLthKXHUOY/uEKsQfSW7mhkugHovh7CPAK9RPSXJDf6Y5C/VZig0mkrGQX7Ty16fJV8AlVlwFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069142; c=relaxed/simple; bh=k07T+F39In0bF6GHHTnnGiCYiH8jJBwsGqiEHYdTlR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cAj/cSQ/tB/44dMFMBEvsVsBdme4nwR0jleTw2OCWtLslVbwP4BgjN1yNj3WadZaDydBOHtOPxELAnTIpY0oie6nUL1WoU6QYeedJyivTYYW08xMx3ErY0jlxOXi+h/KvMO8zOk+8bBb0MK0aiq33dIypre8ZWJj4PwD49Jfi1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iqF6ZGnj; 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="iqF6ZGnj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8C83C116D0; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=k07T+F39In0bF6GHHTnnGiCYiH8jJBwsGqiEHYdTlR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqF6ZGnjQ//5C9N/SIXj4MbRo98/RKIqu3V4asAw4rlaxhwa60YqdL7Wj9zVtIRYV WqlhtHvUpaJ0LOwT4tIm/MRrlkchbGALRtSub59CLNiI+1GcwDY+daoD/fp1Wr9K06 RJwOYuIROALQhJum2weSSWb/owWVKbwhLue2ByYmBzFvPBI8wBpVZvrW7c4VB0ZLbN JV9WMTW1ftYCmAXeXfpGofQgl/zeZ1tu1xMqrVORZ/bCJNhU6jc0ql7Im5pT8V7eKy R0S1IfYaHPj2NwxxDQVwR5sFpRISDGAhwFHsdDUOOQhCZ/Nk+NNncoBSr3qp6louvW koM/LLFJPSybA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDV-35dz; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 29/39] scripts: sphinx-pre-install: move get_system_release() Date: Wed, 9 Jul 2025 15:52:01 +0200 Message-ID: <36abd1990595a79d6a6d479d80fe29f981d1ca26.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 83BDC2E54D8; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=TIXJ4qs+rLqOtfUpOlDSpJKMVAuqwqOwmb1Ld0ARCBYl1L3eLC5oIZsgfARN+iIsYTLuU+7d48uAGF+ayvnP5C/LILQriy1AprxKssmkGPNdWeOGnUSql0wBolrsOlH+PixgpW9uiF1PwmqPkEZX96JibQHAmUUnHs4s8Hd76QQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=mo/BPt+WXf7kWpeg0yIQIhEPp/IOaDGJLi0qzBwKL50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QOxxHkjd2MXVtRnPzBPhEjwHjPQWK6Kjw77jJjgHzdCDBGXdHzCrJG++OLMpilg/qhp21sjpgSzRr5eHRyLH6BNZFQ90lYfNHuCyiH0Bc/KeSF50TtvEz3ij/wLe0GO1o3IudUpzMr4Cf3BGk+2o5p6Dn70R+mm6ZxaFbEOb68o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fT2k3ISl; 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="fT2k3ISl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB631C4CEF9; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=mo/BPt+WXf7kWpeg0yIQIhEPp/IOaDGJLi0qzBwKL50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fT2k3ISlg9JWFXu8/baAgHxAB86OGQ7pG7H8WCO+kZDZ9TqXFPKZOtAyWw2sLb5FW DcllHTn8i88Nbw2GdQaB9MUNLSUqnd19twWpQeGs+yWXWexmtpmPNCE+MksYFIQ2N2 NE0a8Q995wxULcVhXts7OX3YzJV/wUeihVW9jT5fuXAknE9FGmHZani2nwZlePPyw1 /3olgPv86XrnkdeuV046X3HdLlJlZDK2x6gQYUaobzgKzKSb+gNlu+l1jn4zxD28iF EFtJ0R1TygZNo+yyrYnFi73bFdnx8YFHLsHzR7cjd/jgpIlzbfCJjL/RvK52BXpheu zEOINeK4D+iOw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDZ-3Ar0; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 30/39] scripts: sphinx-pre-install: add documentation for the ancillary classes. Date: Wed, 9 Jul 2025 15:52:02 +0200 Message-ID: <0fa2c8115aa980fb6802614098f407067f536ecd.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 96914A923; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=tdStE/k8AwE1DEQDV2olHnvmZExc9wIm768RvkB+01nmj2Xuha1RVujvNhs4deYIJfV4ZePc0uOMEGp9ATHEwJLFKI6cimXc7dN+FnIfPmrTPumDZbUmv/41ghOUzqLp9T++rQAyaYpAJDM2ZF3+0P9nUK0gafWt1UeWKWuympc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=ckGp0WRssE+oimBMmclIVlh9lOxqZRkzDaDvYyhl6lo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sEb7y/aAjmj/sRA4y8DLV8rbsKmc7IcdNruu10TQiMrngWPQBCGht4Osc72S8TiPlYke213UVNs3xD50x2m57u6kMT+EfrfxFwBFi+JXZ6PYtHuN3cXgH6TLwwyTXibxMzzwElK33i3Nzo6JDmhE8UM2EwKQcQsMT5bpsXq799A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pnys81ed; 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="pnys81ed" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7364C2BCB1; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=ckGp0WRssE+oimBMmclIVlh9lOxqZRkzDaDvYyhl6lo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnys81edmiAA9iLWLUEU0c/lIftdgTvJEm1vrj/8rkLLPrTrW6oR9gAgvYmZoMO9F yxflOSX4Y1qRKrjQaMzp3CfYzR/cNOoYceih5fs+9OGMnPaYYit7Vh/T/2AS1YjHKu GGvGqeS2LkmVqsnUFDk19W2zi2uFgVDM+qIXZz0xypmPdh/oMkoFgogUIF+jNhsdgb BqJ09QHZ8G+zHB/a8ulEwGF1dBNj4admf/i8SuhwZa6A6OXIhVwk/SuSFjj+M+UiCW C1kFDrF0BY2Lkddov9JO87/COMBms5evpYFXjTCY6PSk4gKabUScGglk+tnKCDtUsB PawcQAClhxgQA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDc-3GDR; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 31/39] scripts: sphinx-pre-install: add docstring documentation Date: Wed, 9 Jul 2025 15:52:03 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 77C402E54A6; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=nqmgG8ZCyHZSvvn0SsBKtIDBN1wb3mVaHIFp/yq785puxO2PJ+P56qi9lFyFLExt1yfoPmTsccsxTOure/oH6cWtuY53a12evD3ZRSDaoU7fzUHTvapbS9Jk0ULVXyq+UR8U3OmOnJZOi/g+wtMa/WRM2zUeHeeV/+hkuDPFigE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=qA/uqUmIAOWlGTOXnYG6XWQvPfob7ubvzaDqauGY4qM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oz09WnrLxPpVPe4l8M7jrozHLvI04BSaUrZGnF7VLHFepbHjGdAM1fAHMVHnYscBpkyCQx+IDkEGya8cGMS9FdEY4viFSR71PdTp5Ivbi6IqeqhFliPpAt9X5W+mE5OYAZeC/oDL7fWFXSfaWEvogGTdJwOLBbaGUpwACj5gc64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TMzPMACG; 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="TMzPMACG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A96BC2BCB3; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=qA/uqUmIAOWlGTOXnYG6XWQvPfob7ubvzaDqauGY4qM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TMzPMACGJeU/xk69fHdxhYxYoXp9GeMmhcaCH/7PIQNFr2ugVfvs7MOSN3qDp87pp a3B+mIYTCAEcc5PRWfFVHYm8GkQZL0yJTG4pa4zS5sylJVBLU8HWKfmYJD1Nd1sUGe IgiVlMSsWlFhGaLCxmLEb/xHv7mVP+fib0jgRpU33xxUJNBsWwB/rRRtugzcaPXaxn Mxw1WYMP+kb1Yv9k4LN+D5iXo3k6WRc36pyWmu9qKIqHZblCkAflmMRjj1ZsGEKsI5 kjVTm8NeL1hwtGCuibFZHs4nWvVbJWuPaBuVJ93hAeuK3kHMruU4j84jcvzNCSSuhl 67tgcgCMVkQGw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDg-3Kez; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 32/39] scripts: sphinx-pre-install: fix several codingstyle issues Date: Wed, 9 Jul 2025 15:52:04 +0200 Message-ID: <5a3daf7244332e48a1d49dc70d73fb12a765493d.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 87AAD2E54D9; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=pIHCC+33yCbPTdUg8AN4qewAALoFiPjcTaoa7jiAhe2a+LldK2EQhw2t/B5iL3GL65aSiC/GMiocCfm5zhq2uAaBtKULv1ujaMwjvXTh0VKT3kqNCOFVvhF/XtYPhCQml7fXw8h4opCzjAKcsSnWrY6IVFdZ2CEz+EHHMGwmJzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=T/BO/r7ruuwzhv5h5BilZiiuHJFOxxfSdm5kmnIByFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AUcHwTIkA2mV/DEC+wYHTBTZi2eec9CrDZUyB5eSkYIIfhiAE0gFBiLm6OymoGk+l1nRmra3BS1aZqGEcULCuKi04ZOTezLKnqP8XIE7xUgN+IlXNEqkRkTkgj0VoEe5H+7jbnx2Yb49Gu+C7jkRti6/FWPrCBe53PbUkgRv7XA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nRA/3C19; 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="nRA/3C19" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9642C116D0; Wed, 9 Jul 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=T/BO/r7ruuwzhv5h5BilZiiuHJFOxxfSdm5kmnIByFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nRA/3C194bWoeDgBAgbO6R+yeuDwe7Dsw+SLxJa0fUQ1qIJ+cnOHexGv9MQ7dcwc3 CJ4Fz2cVdvhsSi7o30ajQay/q6bvvP4rxN5ET+BT6Lb4qaKyVm6T28txN4Pdkwe6W4 C9ny4qSsOaCKIr5vzq0PdCWCqh1hyiiWqjU9XLIJnIn33YExDc7tfvs9L73Z2tm6na 12oOWhaX5qYAA1q+xtf1QXKW4EHnT0kk0diBXdhHfrMp6IY1ZGMpWwbg8ic+F34Pb+ 3GgVeuukjmvJLbOOgUSY56S/sWL6QoCvG8G8LPg6Z+U65L9BNwtuPMrLnTE8H3BScU 9KrFqmqJwY2iA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDj-3Qqo; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 33/39] scripts: sphinx-pre-install: rework install command logic Date: Wed, 9 Jul 2025 15:52:05 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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 ++++++++++++++++------------------ test_script.py | 4 +- 2 files changed, 84 insertions(+), 99 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: diff --git a/test_script.py b/test_script.py index ab07595d7dc6..2bc6a757e19e 100755 --- a/test_script.py +++ b/test_script.py @@ -563,12 +563,12 @@ class SphinxDepsChecker: # Just remove the entire venv directory cmd =3D ["rm", "-r", "sphinx_latest/"] else: - uninstall_cmd =3D pm_config['uninstall_cmd'].copy() + uninstall_cmd =3D pm_config['uninstall_cmd'] if not uninstall_cmd: print(f"WARNING: no uninstall_cmd for {pkg_manager}") continue =20 - cmd =3D uninstall_cmd + data['packages'] + cmd =3D uninstall_cmd.copy() + data['packages'] =20 try: result =3D await self.cmd.run(cmd, f"[{pkg_manager}]") --=20 2.49.0 From nobody Tue Oct 7 13:07:52 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 C41412E6124; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=aCpTto3pzA/IAOo8vMoAnBQbHplwMHPp2bSoRMInJq2AT6lrADM3dx0jN+arDdgcG5133MQXaXiC0gwePJCdwhPBOEeOpJMEJbN2UPngoquO82dL6663GafPDLgF5aSCCF3lEJDrfC4g4fV/+jEQxTIh/AX4yFkhdaIY2xYkKTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=aokS0IkdFRhl4/IFo4+l7/CezIwWib7/d8o4nBBDwqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L9jW0g8s6wLje01jDIBQsT9QU0ps20JtJFviFuUyheYfVNBbgMAETLN7RgOw8bPwzoPCcPF6+J+/dDSZ79bzobL8RhOBQP+m3XcPhplFEkk361z666dRO74s8MVK28yMGxvEURjAdrl1o2mD/bguaXbm2KTGoSK0+IBbgu9M7LM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZgzYVTa+; 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="ZgzYVTa+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9153CC19423; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=aokS0IkdFRhl4/IFo4+l7/CezIwWib7/d8o4nBBDwqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZgzYVTa+SZRJcCm9p/UD8nA+WfbEfm4AmyIJ+zKLTQoZXMD4/krtekYPTkjK4jBGl Q1oWklJvjz5vn4P1rHzJD75k5w5HwGnKtxz8ZYxiXJCtAebgS8FYBEcNxyYo1I/izE bR/FMCkWYj7xvOo3yHJ/tYVXIkxqrxSWZfo34XWtqdH/4qkcdu/iuwamBCQnkhtJ8H nJT6UQL8VmKvrIyo7iyYgaWg0SG9wOdWPnJYTJe4RRwGtgyTt+/ExAwisPDsob6rpm pW6u/rkbbsTvNSor1NT3XgfFIZ4JAovREhGh44Y91uvK57JjYNv9HdcbbGrZ1xAxqo 0KHWj0rVj9bNQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDm-3WaE; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Bill Wendling , Justin Stitt , Mauro Carvalho Chehab , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 34/39] scripts: sphinx-pre-install: update mandatory system deps Date: Wed, 9 Jul 2025 15:52:06 +0200 Message-ID: <301781a3839c500ea0dfebc7eb2d528d54755fd4.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 7dfe5c2a6cc2..fc9dc45054d7 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -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.49.0 From nobody Tue Oct 7 13:07:52 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 79B652E54B8; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=oCqDHZcykvColnHXcpDGw5FYDRg+sTkIiOHMih6TRzPoQyOzjUzEaFXrMVGImVYy3UDhzCTjsM76p3RduZiGrEXoS5omG1geQgXhju/opp4X6HA+JaRYtSYzob/yBV5X5bdC+ipVpNAAwKvO3y6VetxY4nIcoo9AFoHGBGD1t1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=lTAkg7u8HXaXh2CCMJr0+qB6A4vyNHejb2fT597Jdvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cqzqEUF9Y7ElGS7AQIvZrNjUqbTD8a+HnmMKwMOJF1B+HEI6KtozYPf3OFNaYtCtVhSyYKqpR9v0jVJD6FI60Tv4XQ285vnIZvkjaoeUK2oFZzrkUqe4tGqIGvDmz2xzPrLeMCcFl/ns3hZjDF5MFAmfEniS+7RPgW0iAiTeoD4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LR7FnJLj; 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="LR7FnJLj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 112E7C2BCB8; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=lTAkg7u8HXaXh2CCMJr0+qB6A4vyNHejb2fT597Jdvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LR7FnJLj9AjsOPqevYpq0UNuQfjEeoGmqNL2UbaHF5K25zLAdax2nki60Y73S2QrG 0l0ZIo/vVBPLOJvZMqBvEJwqUAz3qFhEtz/qQavirgUbVjMHr4ZVeo3XbEw7TsQblb vPXkLPrnbcP+BZij3c/S3Ti8ckBMpSwouViAt7k1PQNmKbItXTlVUx0uEzfVRe0mEX 2VhakPT+VcJm140OAOZwVxsuvB5ZaPLo8nmRC7BQf/27bxyCrIJK6+9NptyTqV+N4/ OwNrcFYGaVcwKzJ8/xP0T/bQIwhJFAWKQs7em7SoiGux0YHQPMK6EJbmUI2b7VTG/p O17IvXq3n+4AA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDp-3beU; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 35/39] scripts: sphinx-pre-install: add support for RHEL8-based distros Date: Wed, 9 Jul 2025 15:52:07 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index fc9dc45054d7..324baa98a395 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -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.49.0 From nobody Tue Oct 7 13:07:52 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 791A72E54AD; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=W0obnz/eA8IYBN65Qtm0QYD4YVHRdzeKTcroA+WqLSSd2zUXPTeixAZOCLh/B3dnRUlatXo65tXGPLyJyqNRllHMyaDUMXW/zBErRKyO7Q5Z7wAyTiWFrJQ9a93XFZ3m5M1Javig/K6mNEDA5xXwMDwfPpPdCzUuYjDuGrZci34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=c0eqVyycu6+AkYkbP+HjEPSJRkmNcUy3eyHfhwOYGrQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IftZx4nNp2XcknyRj7OM/T0lmqCBqtSjvX+5ulrE9Q+4/WvPAFcuEUyLSSHLYlGl4qyfX/SIGLsHazazYLO3yrWaWU4uYOF9QpXQBW9/Um8rWc9yhrfcgpw9MhZYVeW8+eXsc5IF5D1J7RpEw04R1x54UamyXJ9gvLazWRH/6N0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=THV8hjm7; 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="THV8hjm7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A9A4C2BCB6; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=c0eqVyycu6+AkYkbP+HjEPSJRkmNcUy3eyHfhwOYGrQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=THV8hjm72LyZiAHIgojHef5FqEFbEiYm4kCxvNcQRVuemg1qUwXmKL7nzTK3alvpo uTg9A/pEd7TfMHbED9Gohb5Mm3hq497WSCtszebD+MnCDwuuUbkCl4q1VRJArDJ5x3 935bmsGgZx6mhLayLWwVC4jGy3vIuinbb+1RCc3FgeHSl6+3KBeLoL6/ISvMloi6UU 9/DAs2c0AdshxKIvf1Hp8NR1OWrhLN81Kp88b1bnUKT+AC+RtKqv95zpFknccqjvdZ anw+Jue38Gfg+gKaGV8CK+iNh4uqLlSQkdte2DsirdOLboWjg1WXm3ARXHOEQulRxk 1scTcRWk6lHdQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDs-3hYe; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 36/39] scripts: sphinx-pre-install: add a warning for Debian-based distros Date: Wed, 9 Jul 2025 15:52:08 +0200 Message-ID: <98e16b2f57c5a43074c3c03ec8758d4fd1107388.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 324baa98a395..09a337509b23 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -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.49.0 From nobody Tue Oct 7 13:07:52 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 52AF62E3AF9; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=SWfwJ7iM5ccvreb03QMAt03RjNXSAgniWEHIYGGgJyAm+VfcyBup171d3NSU3e5I4wdfpHTjXa/dhNiK9YVf5XmLlI7F+fmC2HlZ2RRbxXbu+9L3rzrONUAAC9Y9x39IZA+AwoujHN6T+rrhLkT8c7sMSqHsi/pIoflFINuvsEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=Qa0I6IanQu0oRpZuMvSwsgCMF5vqUA+cZZbiygIZvmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZYA1XqqlSGWrJpKTIG6aoy85rP/OKvPTa8NDWeETFJspi8QxWPCXaKeEqQq5rXS3ZimiefmfISNQ3mSfqvX+wUNoCJzQL7qopnPGy5XzfOFH1P0vMMac1SDbuVlhmqE6XY0O4AjlEOS3nL6j6/lsXSJlfGjQ5G7jdDJaPAspfak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f9wANGiS; 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="f9wANGiS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10B9CC2BCB5; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=Qa0I6IanQu0oRpZuMvSwsgCMF5vqUA+cZZbiygIZvmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f9wANGiSjzurF35NNxyLbzbwmIgKQvw9uVgRjPgVxHp3fT7erhC5sMMwn6lJh9Oxo K73NMr8PVjUfjkx/VX3C5Tbea83uoAOoeuxhEb662wCB9IM4sD+BlL6Bx0UyRqpMHR +83Vv5/h4uqeEYw5VAVlpBtsntVAhoZdkUS5T2vNdTE8ulPCTOZRchKbWD8jhgBlU3 Y+7sGWbbKgpQJalJ0Pi9ttSJKaNshe/oGeEcS51ng35DS8XMygqTNlQNw6N2e02DWb fMohIbZ6PKJ98iv5ZijzfxTBUysUQEJb0LT5YH6MRs2fGJKm31uSfs1zTfbgt+MGZG DrgDaOUhFaY9Q== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDv-3myg; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 37/39] scripts: sphinx-pre-install: some adjustments related to venv Date: Wed, 9 Jul 2025 15:52:09 +0200 Message-ID: <7a83f92a31e38452ac191e5bc56be8d4bcc48495.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 09a337509b23..b8474848df4e 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -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.49.0 From nobody Tue Oct 7 13:07:52 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 52BA32E3B0E; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=BHZQ3Sxvr/NDxY/7uD3Swt2/RAgIdsPixEj0tMCaLNPbxySEAwCiB7L1n+0J79XXLIjLsEWh0pDaN2ftoTv0OtRkCKc4F4630xyuxzDDUu6hikyQ7YmeEa46Rj0CpQK5TuHGFlwCTFrXi/4Tiao6t7wq65k3ht1pgG40PPSHEkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=75GiMI5XCY8qjELRgZ3Vc7ro1BQ9wVlsucAKGUjaS/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I5ncATvIllZf+QVxaLygym32ZIC35PfdxT0TbBXzvHBzukMLrf0jXs9cT11ja0HuOWcZbqGC/MmbdaCf9RuSd5Z2Frl43Avrj7lhnnR+JCNUCs1P/C7XZlALsqSa7/V40tMbdT1KxozkV1gHw/KwCbHq2YiBjRChyRkYpBvZBK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KPYVZqDF; 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="KPYVZqDF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 142E6C2BCB7; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=75GiMI5XCY8qjELRgZ3Vc7ro1BQ9wVlsucAKGUjaS/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPYVZqDFm9gN+x+ZwMlAmFVXp4qhoBrYrQqtJur70myQmPcZ6mH6ClpvjNkgfy3fW 4ESJe+YyjUlXz68Bz6FAl1IW312OpD7VRUuqUo8DEVFOBmeL3Z99wdF000yCpkSmHv 2vQmwRWbeb6CWPUVq4VXYK4hgk0XUhUtI2CkqxNRYL3V3zb9cZhqx2Wh3iJ6SbVY60 +Gu0EfSEXhB8JcWA4OeotC07jfUQwTaf9V49UQdcgiRidytQZKICE4dR76DXyR+JnZ P9bcT1tvEYQuKyHlVTvXXB42hIqNv4q4hoGPMf9VraaMHD32OK3s+hw5kiA9LLBQek upmdaK8UmP8Bw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EDy-3s32; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 38/39] docs: Makefile: switch to the new scripts/sphinx-pre-install.py Date: Wed, 9 Jul 2025 15:52:10 +0200 Message-ID: <10acb9930e6505c52d89a649bc89601fef116cda.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0 From nobody Tue Oct 7 13:07:52 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 9919A2E5B1B; Wed, 9 Jul 2025 13:52:21 +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=1752069141; cv=none; b=ZiY4DkaBkmGNzgDhW/haaGmfsNB2/+RdSsqL5BZIW1Il312n0SSMm5DPSqmuWQRQfBO1NIk1fpcTpu+SVCz8894qOpX3o9XojlhqzZsUEgpeHLPV/6SwQXeEJM5oIs+0oz/mugvrOiTxHoUuVVTRUQ1PYpC3+M8IFtGXl3eB4ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752069141; c=relaxed/simple; bh=nJugNaI/eficPJxi/nd/TlNw0IlCEXQxm2XzLRNF8sk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvtXwrrFrnUba49o8TlHp5rz2INcsxRONnfMMYialuzrKTrl6pMEwMTMySRaY4Oh867+keVuVmOWt8/7TZQ/flNBeonhcng9tONPgpPesdcoeif2TbUJmxSd5HjpyRkAezMVlFU/86MWWQMDBk67KnqR1uk6Fywh428g6cweDmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mlWOYAKR; 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="mlWOYAKR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00B1CC2BCB4; Wed, 9 Jul 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752069141; bh=nJugNaI/eficPJxi/nd/TlNw0IlCEXQxm2XzLRNF8sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mlWOYAKRtLp48HWHMEcLp3UcQVE7wq8DK6xW5d6eKsrW3aqTuvIiJEIMIj+KwPkSS SbNPAaS2mmyqI5swb8BwuWQ2OKJJ0P7YJdQg6/w3iA8NICIDB0ewNj/GZq2v6OuV4L ZWV5ZOubCIImvGL45A/90O//QWYnJQDAlOnOVpVFoYYtgXG1sf0glI2MB49cJZ7n6y c32lgksNkWR7kfVKgmEzWetVj5dQbjxV6TCuqtqf73N6ZH5OrIN+KE26BIwQHyDb5O ZNEAuIs7ywG/Zvb61WjX+NFRXp4B2Aje7Sh91HVhtbGlm39yUY145CrXAAWP7DfP6J BJTiVQX3Mae4w== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uZVDd-00000000EE2-3y3Y; Wed, 09 Jul 2025 15:52:17 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 39/39] scripts: sphinx-pre-install.pl: get rid of the old script Date: Wed, 9 Jul 2025 15:52:11 +0200 Message-ID: <930ec22345cf72219c59098268150a4a1b086503.1752067814.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 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.49.0