From nobody Sat Oct 4 22:18:29 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A12EC2F83BC; Tue, 12 Aug 2025 15:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; cv=none; b=Dpbb3IzMM6pcUc9fMgyHkqQ1V67vJaYd5XeVkfj59ocCESrVqefEIzZSXH1JK1bBwXgurM8WTpOq8lawf7VRf43ov+emTdoNm2/bKOkb4pzirgrKHCCpvXb+BuIxozeQBYgEvON3fIHFMoN0VMtC9OqUM0xJPeYPjYakDfC1mx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755013985; c=relaxed/simple; bh=2YsXAMd/pCiQ6uIzzxaRELl35dvP/BI9lWiGv4U9Fk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CahX2k8r7g0Q62RbVMlGBFqHBSoih/qpjLWOkaUHq5FMv5UE5dRBVEJjesQ/E9tUIJJb/k0zAuzr4Q+YRZXEfgOYBR0gwmjOZdRIN+fBgdu61ycoG7IgH9tyo1g3OTyQ7ZLxXb8YWwjOFER5W7QTxeaVvnFlKWU7CJnb8xq1O3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7zLsrAS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I7zLsrAS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E43D8C19421; Tue, 12 Aug 2025 15:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755013985; bh=2YsXAMd/pCiQ6uIzzxaRELl35dvP/BI9lWiGv4U9Fk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I7zLsrASYMz8iMRtwIQuFxK2wMbcAz0MyUbU0kvJOj/v9BdYMykafy1H7JV1CfBsf CogXXNjilQNsiL0HvKywdQtnJqhs6jowIGDBt8Uaa7bzWLZG4C8ghuFN+EfqmTVlvC +xovnQ84TI9AgETr8yVP1nr7Yj3wygSE45sTOxFrGKmYnDpq+KnvPgffV5FMDkVlRH mceZ+UppO4JRvrtNTsSj4S1ZelRiHhshCAo4DbwkUucmbcX6/FIy+Vg3mys0Qttahz yiifo26yCwXKL0Vwe7ewB5gn2eZWCzVfnxtgllD9h1Ts0HZzkWejWO3iUEoFBaunPt psE5SZq9AJI7g== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1ulrJ8-00000006kX0-3hv5; Tue, 12 Aug 2025 17:53:02 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 28/39] scripts: sphinx-pre-install: add more generic checkers on a class Date: Tue, 12 Aug 2025 17:52:45 +0200 Message-ID: <11a252fe816bd7c85583d26ade0666eb2b481bf0.1754992972.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Better organize the code by moving the more generic methods to MissingCheckers. Such class contain only binary and package dependent missing checkers, but no distro-specific data or code. All distro-specific data/code remains at SphinxDependencyChecker class. Signed-off-by: Mauro Carvalho Chehab --- scripts/sphinx-pre-install.py | 142 ++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 66 deletions(-) diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index b00e50028f4d..9127487bd4d7 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -150,7 +150,7 @@ class DepManager: if output_msg: print(f"\n{output_msg}\n") =20 -class AncillaryCheckers: +class AncillaryMethods: """ Ancillary methods that checks for missing dependencies for different types of types, like binaries, python modules, rpm deps, etc. @@ -261,81 +261,24 @@ class AncillaryCheckers: =20 return subprocess.run(*args, **kwargs) =20 -class SphinxDependencyChecker(AncillaryCheckers): - # List of required texlive packages on Fedora and OpenSuse - texlive =3D { - "amsfonts.sty": "texlive-amsfonts", - "amsmath.sty": "texlive-amsmath", - "amssymb.sty": "texlive-amsfonts", - "amsthm.sty": "texlive-amscls", - "anyfontsize.sty": "texlive-anyfontsize", - "atbegshi.sty": "texlive-oberdiek", - "bm.sty": "texlive-tools", - "capt-of.sty": "texlive-capt-of", - "cmap.sty": "texlive-cmap", - "ctexhook.sty": "texlive-ctex", - "ecrm1000.tfm": "texlive-ec", - "eqparbox.sty": "texlive-eqparbox", - "eu1enc.def": "texlive-euenc", - "fancybox.sty": "texlive-fancybox", - "fancyvrb.sty": "texlive-fancyvrb", - "float.sty": "texlive-float", - "fncychap.sty": "texlive-fncychap", - "footnote.sty": "texlive-mdwtools", - "framed.sty": "texlive-framed", - "luatex85.sty": "texlive-luatex85", - "multirow.sty": "texlive-multirow", - "needspace.sty": "texlive-needspace", - "palatino.sty": "texlive-psnfss", - "parskip.sty": "texlive-parskip", - "polyglossia.sty": "texlive-polyglossia", - "tabulary.sty": "texlive-tabulary", - "threeparttable.sty": "texlive-threeparttable", - "titlesec.sty": "texlive-titlesec", - "ucs.sty": "texlive-ucs", - "upquote.sty": "texlive-upquote", - "wrapfig.sty": "texlive-wrapfig", - } +class MissingCheckers(AncillaryMethods): =20 - def __init__(self, args): + def __init__(self, args, texlive): self.pdf =3D args.pdf self.virtualenv =3D args.virtualenv self.version_check =3D args.version_check + self.texlive =3D texlive =20 self.deps =3D DepManager(self.pdf) =20 self.need_symlink =3D 0 self.need_sphinx =3D 0 - self.need_pip =3D 0 - self.rec_sphinx_upgrade =3D 0 + self.verbose_warn_install =3D 1 =20 - self.system_release =3D "" - self.install =3D "" self.virtenv_dir =3D "" - self.python_cmd =3D "" - self.activate_cmd =3D "" =20 - # Some distros may not have a Sphinx shipped package compatible wi= th - # our minimal requirements - self.package_supported =3D True - - # Recommend a new python version - self.recommend_python =3D None - - # Certain hints are meant to be shown only once - self.first_hint =3D True - - self.min_version =3D (0, 0, 0) - self.cur_version =3D (0, 0, 0) - self.latest_avail_ver =3D (0, 0, 0) - self.venv_ver =3D (0, 0, 0) - - prefix =3D os.environ.get("srctree", ".") + "/" - - self.conf =3D prefix + "Documentation/conf.py" - self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" - self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] + self.install =3D "" =20 # # Methods to check if a feature exists @@ -460,9 +403,9 @@ class SphinxDependencyChecker(AncillaryCheckers): if match: return parse_version(match.group(1)) =20 - def check_sphinx(self): + def check_sphinx(self, conf): try: - with open(self.conf, "r", encoding=3D"utf-8") as f: + with open(conf, "r", encoding=3D"utf-8") as f: for line in f: match =3D re.match(r"^\s*needs_sphinx\s*=3D\s*[\'\"]([= \d\.]+)[\'\"]", line) if match: @@ -513,6 +456,73 @@ class SphinxDependencyChecker(AncillaryCheckers): =20 return True =20 +class SphinxDependencyChecker(MissingCheckers): + + def __init__(self, args): + # List of required texlive packages on Fedora and OpenSuse + texlive =3D { + "amsfonts.sty": "texlive-amsfonts", + "amsmath.sty": "texlive-amsmath", + "amssymb.sty": "texlive-amsfonts", + "amsthm.sty": "texlive-amscls", + "anyfontsize.sty": "texlive-anyfontsize", + "atbegshi.sty": "texlive-oberdiek", + "bm.sty": "texlive-tools", + "capt-of.sty": "texlive-capt-of", + "cmap.sty": "texlive-cmap", + "ctexhook.sty": "texlive-ctex", + "ecrm1000.tfm": "texlive-ec", + "eqparbox.sty": "texlive-eqparbox", + "eu1enc.def": "texlive-euenc", + "fancybox.sty": "texlive-fancybox", + "fancyvrb.sty": "texlive-fancyvrb", + "float.sty": "texlive-float", + "fncychap.sty": "texlive-fncychap", + "footnote.sty": "texlive-mdwtools", + "framed.sty": "texlive-framed", + "luatex85.sty": "texlive-luatex85", + "multirow.sty": "texlive-multirow", + "needspace.sty": "texlive-needspace", + "palatino.sty": "texlive-psnfss", + "parskip.sty": "texlive-parskip", + "polyglossia.sty": "texlive-polyglossia", + "tabulary.sty": "texlive-tabulary", + "threeparttable.sty": "texlive-threeparttable", + "titlesec.sty": "texlive-titlesec", + "ucs.sty": "texlive-ucs", + "upquote.sty": "texlive-upquote", + "wrapfig.sty": "texlive-wrapfig", + } + + super().__init__(args, texlive) + + self.need_pip =3D 0 + self.rec_sphinx_upgrade =3D 0 + + self.system_release =3D "" + self.python_cmd =3D "" + self.activate_cmd =3D "" + + # Some distros may not have a Sphinx shipped package compatible wi= th + # our minimal requirements + self.package_supported =3D True + + # Recommend a new python version + self.recommend_python =3D None + + # Certain hints are meant to be shown only once + self.first_hint =3D True + + self.min_version =3D (0, 0, 0) + self.cur_version =3D (0, 0, 0) + self.latest_avail_ver =3D (0, 0, 0) + self.venv_ver =3D (0, 0, 0) + + prefix =3D os.environ.get("srctree", ".") + "/" + + self.conf =3D prefix + "Documentation/conf.py" + self.requirement_file =3D prefix + "Documentation/sphinx/requireme= nts.txt" + self.virtenv_prefix =3D ["sphinx_", "Sphinx_" ] =20 # # Distro-specific hints methods @@ -1187,7 +1197,7 @@ class SphinxDependencyChecker(AncillaryCheckers): self.python_cmd =3D sys.executable =20 # Check if Sphinx is already accessible from current environment - self.check_sphinx() + self.check_sphinx(self.conf) =20 if self.system_release: print(f"Detected OS: {self.system_release}.") --=20 2.50.1