From nobody Tue Oct 7 14:56:24 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