From nobody Wed Oct 8 07:40:05 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 AFC49239E7F; Mon, 30 Jun 2025 21:52:44 +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=1751320364; cv=none; b=Erono8S/uzbWnrCzc8eiFO6JY1s8vojWsR0cOLNXUQBRzNm5eDyuh9Cy4NGuQXS/Z1NXa+CeJs5Xlq1vSf3FwlSJJ5Jh8fAe62nbzKC//ANkycz/ODW1du9lb+Q0z7fBQWSQ1HHIF9DWYQlkACME8eKxiT7vAJvBizBxA15iwg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320364; c=relaxed/simple; bh=tRHbxQ8xRhDpil6Zr05w8pog9obBdefehr/BAJUtAVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JeK1QVeI9auIiLpbHVOnWjQgr1+DRAcNBigKKvn+3LqcQNbHtAUbDPgWPU2GxWryajHxyAasD9q5lQ2SR9WhD7Hji4KCus1PAQpsX5QizecX1zPozUck5NNkSEWFy90n7RysvNpFFVAP/uXhg8qapKMeQv4MpelvyMx+uNZgMaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Lxi7wC3n; 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="Lxi7wC3n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BE9FC4CEEF; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=tRHbxQ8xRhDpil6Zr05w8pog9obBdefehr/BAJUtAVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lxi7wC3n9/1SvuETVUF8+kHukWb/9MSKM+xMagidHMoEAEyfwbajSmVvYY8qGt3I9 dBD5rBAO8OCQwomJcjX2XQwHkNHTBc9vosdJhUNZ9ATGjT7YaXeLGV3D3pbktby5Ms 5rTxEmf1A6NfD/zQpCfGT0d3p/48eVS8CS3c5Ht4NRe2A+MVj2v7Qd1idRAGhPKHHe iyqGRBmGyLYPkx50NBmESQbqt2uhunM1uZ0L3kFHz3B9EK1/OKG1CZuhhi+WnAocGn 40YvJiGEB1R8IZox/N/5aHxCdmT5/+bb4SPq0ndNH3T5RVeHC8mXEvkwhXt669URxX o+GKk0y++fojg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWJ-1aTO; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 01/15] scripts: sphinx-pre-install: fix version check for Fedora Date: Mon, 30 Jun 2025 23:34:49 +0200 Message-ID: <05f9d16f8a4d95ad7a1d26447d6f600a99e0c92d.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 BD0FD23F419; Mon, 30 Jun 2025 21:52:44 +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=1751320364; cv=none; b=RFpVOKobTseCQ9RDcP6k3+caQLBJclN8KE4vRNWgb/oLiRvP4Iyqvx77DZbzk/cfHHIk3cqNYCDJbKH/KmelvJrZesW0Ngtr+JBxnjWdGTiFKBqRmHMuEeokwR8r/D23Tbna8ALPc0psFsv6deJ+q0GjbUYkt7j8cG1SbSbLiNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320364; c=relaxed/simple; bh=EbQjzz4Wn2NcXKYSjIXnwavVPRnv6w1AGbo9KYaA4sk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AgAR4LVq6a9KYG+LjcRTu0pQcLlC0WbihJjDgTYQ50shFARFmBCeuYECHZqYHJ1jVr0GWCBACoWEm6Oskk6JAFxNxS/uSv5Jhfn6juLlHa8487Bg23ER1ZiDuAWWVtkqnBJNFpOeWOeZY0m+et8rtkrsTz2bjuL61sSSVHtNZxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LpS9xL8V; 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="LpS9xL8V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AF18C4AF0B; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=EbQjzz4Wn2NcXKYSjIXnwavVPRnv6w1AGbo9KYaA4sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LpS9xL8VZqmBUau0mJJbs+N10fHTtsA0roON6F7ZvioLJ2TJna/frWUZgQJZIMcEJ qhpG2xzb+nYypioom7V9Gn/SdhTtfVPK8FJYKbTNwSZHT9V6nvyhZPmlNh3V+iOVFL TisG8wbJ08iP7uA8Kf61ntYHuyXh9qAgjAIdx5LkfFGWoCH+thSqwMLzX/M3BXD5Pu TgDuPnl4qHB8Og5/UsE5huXxR2NJ9KjsYLlgPdHTxoMKBocS318GAPY/Y6vtySD8wu ApgNT6FpCuGLDTaOvnyyT4BE8yC0Lg+dF2aa4yIcimW95jZRJss7qwo0F1Fkr3cFS5 mrveNchimSxLg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWN-1hOm; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 02/15] scripts: sphinx-pre-install: rename it to scripts/sphinx-pre-install.pl Date: Mon, 30 Jun 2025 23:34:50 +0200 Message-ID: X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 E8ED5242D71; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=mvbRvbyNEe7LrfBQhrCTynV2pA8gLK6rwsJHgM+bRSFAXmt7OFFofyKPHyGM4EKbQNPvjwJhdqCZmIuz+Hfh/kUin/R831W5bCvNLVTA++yT6xyfnVGt6KrK6AG5tvtf3Y7VMPgYdWkaFKIN1ixi5Vc6kT77M9M+lRynjp/Wr9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=MNOXgSO1XMRjiM/GXHN60Vd+5xeiT9wwWbv8HWdaP1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m2aPkI6XJzxsiMt5ECiS62pH6jfSE5WClrSz2MYggyedTSFrL4dlYrWDcFoUEiGvl4XlxFh+4SChJ0EbqJyDjxQOH6l5eLR0vxWnsIdB7Uv/zolVaw4NQildAIRL32lm/5WGusbGRNMcpcgaqUF3KSNdjpat2sCpaCHR9GY2bPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QfwYWohs; 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="QfwYWohs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49A3EC4CEE3; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=MNOXgSO1XMRjiM/GXHN60Vd+5xeiT9wwWbv8HWdaP1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QfwYWohseU0FCj6otXN5wIeVXfRqbUAYiylKx7KJgkffrglEvXZjpUfqqsWluf7UB 50jTKg1I167EBTpm5GfaLzVhZoVCjSZsqX2cMCOr380IPLY6Kw1BBKaMjmCUrf+cru Zm7TgJsjSODEFlygOcRQawSdCzmRktYbnkKtOo87vghjm++J+GqEwGGlIgL4+JDJ4x YojnY9kwaHzLAf75HwGJVQrvRhECPoqMwOLh7WJ3PxDl+scLHJR49txJmhodIhsIu5 W41yMbx8Xdxpj0/9+bj2Qe7PtsOOgGj6M0olYTk52ZPech0YkGcHQQ9khnL8JRQ+EU jloXeuvT+0d8A== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWR-1okF; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 03/15] scripts: sphinx-pre-install: Convert script to Python Date: Mon, 30 Jun 2025 23:34:51 +0200 Message-ID: <7f60cf37bfebe0ae4692c1777a9346963942d583.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 AFB891FBE83; Mon, 30 Jun 2025 21:52:44 +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=1751320364; cv=none; b=NBHr+tkDUxQmXg4TmBD3v7iy44HdgHj3SdXDePeZ/pF+yHuVHLT1OBQveaSyc8/qDCgHT9dYPQTkJ/ZNt+IMS23CIUrkPoBpCEZ81ZX6thhPBRsDW5SqFacxk/xrZ7SxyvEHOIJSwTA1wP1F0nQYroR+d8e58QWKYEBM1jZ135Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320364; c=relaxed/simple; bh=hGjOw2r0fOgFBqLa5A9OTo5yzmBwEcGTq2ZPy2TyjdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lufe+70U36DUrpUvH5dnDwIAxWzIVdLMHFMvwEe+o/E/ggf2BNGLqhdF1Z+vwByLfJmhteZu1LEoYoSJ3Xo5B30YqS4Adf2Tq9ORzWRKgTemqlqsIUeylRMNypgjmcJ5KMNMzQCovoJShQx8d8cMxV9NNL+5fcg9Awt1TGUEguQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g1G3VxJN; 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="g1G3VxJN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E36CC4CEF1; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=hGjOw2r0fOgFBqLa5A9OTo5yzmBwEcGTq2ZPy2TyjdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1G3VxJN533RDbP4dLNVHVsi24d7OYwtKtnoGYqxfH43RyuM8xqeOUjs9GUP4r1R3 WMmuzn1K6r4wwnqTi8sspoUdWmxbyhWGvPQkvioQ5KW99f+/hRmm3UzPORb5+NyRtL HV1NwJ5FWEkD/c07ZMofY82y7cMnUG+BsNOx4TqDV8P9uy53VdJIj6e1vAeHf8P1vD AaG1ebHP3WIi5gbwLMJkHZC7comuBJ8H53pnXWNawDhNPhddHVzUwX1kIC8orFJMi6 atTc1um0Yl61svVC0sDhQ8Bjg6k4XbcN6RoP1HgFW62bRCwxjZQWA0zz1UMOuse+26 2qOSC2hvHNbNg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWV-1vbc; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 04/15] scripts: sphinx-pre-install: Make it compatible with Python 3.6 Date: Mon, 30 Jun 2025 23:34:52 +0200 Message-ID: <95f7be22f5bd0f3eafc8406bc0e1ba4da0203880.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 D4CBB23FC41; Mon, 30 Jun 2025 21:52:44 +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=1751320364; cv=none; b=EAvc9/1vb0yzabJ4JThs2tq5c1AYf0SlyI056CbdMIFI6R1IR5HQgyrnFclgkw6cYquXJWEac6aWiAYSzNM1AAk2GNkTvLxLMO/tzRQUHHhq3Ag84TJGzH927b81kULsWR/UP77tFCe8dbfq1KKBsdOl+gdQMZzl5fs3MykBHKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320364; c=relaxed/simple; bh=QjBAfeS5DM8omDHphHQWuNNvVBS8lHexNOTGjOEFji8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DToYzX3brD+zAk0BRZqnBLBO05PCmxsN0ijwfuVAi6NRANTR8E66Mwv8y4DsU0r/LE6D/GhU6puBmcV3iybHujGyUxHmYf+idUm4ApS8y3u4FlItMUXYbXhiSl7lixESPML2ffgN6mIZHgOoWQBkElVtr0esSVyPOrEGftu32Lc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pq6PCBZb; 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="Pq6PCBZb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58B2CC4CEF5; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=QjBAfeS5DM8omDHphHQWuNNvVBS8lHexNOTGjOEFji8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pq6PCBZbsdYW240cehsEjxo41vfA2bdxPjwxIV2KQxOn7ctwElPjO3twlSSmYyhPy 4vsG7HFfAaTXRHHnJUhaJaGGQKIgtw+2jJVivpEPToCYf+mA8B2FN+8YrvlY87hR20 RqOnYtgLGxPPL064S9Yt2mnKAEfY0hMiklaT2rDZbsWs3XdGH8E6yM1MUXQzIOMGCU 425FkfaH4MntHNW1OTnZ0nSlmICMcy03BUw06hsnN9TTm9YeBUgNEVvF+Tsnn9OdBt JWC8QozYZAfHQIJytPbTH91EoZMNR2oLQiff1ccWysW+xmZ80UPA1BxVYfB0jRKJck 6jXFdTHGHJ7sg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWZ-22Q1; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 05/15] scripts: sphinx-pre-install: run on a supported version Date: Mon, 30 Jun 2025 23:34:53 +0200 Message-ID: X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 AFBEF2367B2; Mon, 30 Jun 2025 21:52:44 +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=1751320364; cv=none; b=dle1iNHsnDO4lsljdWO77+PVLsIFFe3THZTgNA/r3EQjzwsmJf3wR4THORFyukS6gHKKchQJsjKhAXM8G0PjggYZAmva7E+A1s6wBrbjYxTYNOyQEM0ZYJAIyZ4n9U0VD7ymRLcua2X8NYnEitcUJD2sTgtgMNMDRm0VDQ7cgpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320364; c=relaxed/simple; bh=DHtfPYJYXR8ddBt77pelHOR6W6f51lVt8KBAeP14qlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uiceutQNcYRUAeSsz59SulXp7OplwRDF4LAXAWSkIcfrRld1c1z591yRhIEr4yb25WkbWHHhl5KlfPcYlBy/+Z1pRFtI4d6iY5NlIMoE0TJWIkBll3LCTgYX0itZYxyiMhJBfksju0Zj0HURPC1Z7axVcN8wM0sVyEsnFfa9dvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c26XOtEC; 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="c26XOtEC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 568A6C4CEF0; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=DHtfPYJYXR8ddBt77pelHOR6W6f51lVt8KBAeP14qlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c26XOtEC+BRg/drzRLy48xwhA4h+bhz6bR/IgPX0q0g0LOlcHCkksq0A0vq5UMn0p tfJ/PwHaZALWHEenzdW6Egbn7NvOQ/sZqh5VrIWMHt3w63NdcpHNnoeBuUDwE4cySf z08/he7zTvtQTbRTFo8FKhOCm394Xz8EX9QH2FiNvGMQXzGp8n8taH+lM2reAJplpk blWxyMISw0mD6lKhHHggOzgnetldOyqSFhSnJTbKVL++HfUjSn4wZGx5I4uXokfE2D C8FLvMwvdNaQB6cbJ0WoPF3ZdI0bBB8wm1WaTWMgcJsIDrDPnyTuVcra/ATwylZ5qp gAt9ajqC7JWvA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWd-29GE; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 06/15] scripts: sphinx-pre-install: drop obsolete routines Date: Mon, 30 Jun 2025 23:34:54 +0200 Message-ID: <1287964385f0df25c2b0cf91c51d1dfcdeaea8fc.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 8C3811EBA0D; Mon, 30 Jun 2025 21:52:44 +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=1751320364; cv=none; b=E8eqUEibCNMmT/fIXhaXt8crm2kzz/J7uShlVOl03FfrPpfsyfzc7T0IurpO5fFhMEwXf7lpCbhziSXqz//w9ghY+A3E2ZY1LXw2n3Yn5cciRejIRKcuzq2A5Ld4eWEI17t6V0ubKI7/5GRekxFU6+Y7c2KfvVQys0Fx7QXVKcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320364; c=relaxed/simple; bh=ZwhknBqlHdkBeAIFTDnGtCR/SgMMaoQkTrq3Mjl5ySI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZVam6R1OZEYwSGzo4wxkkVLc7yCcqerw55J95HFnVeWBfZNvpdP24pImFgA8uHTfhUML7ApVslzLNv61v1FfHScAStF5K5GdOPnG1A1BR6/D5XwA8MOB0WgUR+joWIBJonDAnP7olj9t/zC12Iqdux31U4d12b2qWFUK/jW6aDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bj5xMQTd; 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="bj5xMQTd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54373C4AF09; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=ZwhknBqlHdkBeAIFTDnGtCR/SgMMaoQkTrq3Mjl5ySI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bj5xMQTd/AlShkhpDFPAAnYzd/ZXaXZ+ZXMCs95/aFVD3fr8bH59+3BHnw7hRXN6i exrLrrkEmyhP0UmTTPSIfVI33CHyDzDCgCLpGoLi101Kovjo8d6fV2vynOA3EROakH yZ35//HOVrlTVnvTasAs0mqw2+64JkSML9OTGHg5XywvvSweuZfFEkSh1r0PQWzO0k yIKOzs4O5DwZHv00jxzKKwWy89nc+ru3qaLjZvZf7ktxy5cHoT6/Bb3od5HKrrl2cw Du0OCvq80ovKUuJ2cy4E1yhA7iPFamp+s3WaRUvnTaCjZZKRVwCbXg/xM0jD5SeGv6 bUdc3i2J5QyvA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWh-2G2Q; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 07/15] scripts: sphinx-pre-install: drop support for old virtualenv Date: Mon, 30 Jun 2025 23:34:55 +0200 Message-ID: <000c49af2cedd9e25b7ceacc3d69be8d73c876c6.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 F3647242D8C; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=SgrWBnUuMAgNna7dA7PY0t4wSUAdh1gnD2R9/88cgOHFjkjUJr7jlzQSAvE2G/5fWNeY62L8X/n+DExez9BDHD4F7XIBfa5B91mOj2yw/Cz4cazSwObTAiYYiRwIXKj6XKc5I50QMc3oCknZpNPtItAAPOu77PXu430s8nRTmDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=ibyDFfdHR/o/ZTsMrzSIxlRYX/epHuKw1deAOw9XBLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F9qw/YWbFqw/qZsVoN6cSLcAx4x2Ms89CWCac0/XjSkQ/Jzc9j2K49B75M66ZXfc9adItFf5v/hKnODWgxNuJ7KoMMHnQaoVINiu77w5pn8c+YUdUKi1fbhq76w5y3xWCaR3dNh5sY7FW68PZF6/+MqalKZmTyT4USINOljd9hc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qCX2LGTo; 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="qCX2LGTo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D89DC4CEF4; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=ibyDFfdHR/o/ZTsMrzSIxlRYX/epHuKw1deAOw9XBLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCX2LGToglU5BugwCVGf5Qs1+e+NMWM/TLBRHrZ6XAbNQP8H0oYf+Hw2YwtACSYSH OgyBewFq9JxtcOK7+S6kCVbReDT+mpZWIRwW7gZQJA3wWr+U09OkRN/ZhEeu6W67/b j/HSPpnHEmVzArJptDWsydOgbodTLD3eJP08rLGpuB9nByrjTzOl2T6ZxCOSz93+ns SJyGXTqihl9gdvniRXYaLwFUjHIUqw/N5FYnhqZwZK1PitLtp7L7L5FVgLwsfs1hhD qlJqYaDvGFAkLLeaGpXAjfGpQYnwd1+aGymPn6oaFBjbLQPi8ECfMRp1I/+PEvBxjd qSp6JLW+EIbjA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWl-2Mrh; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 08/15] scripts: sphinx-pre-install: Address issues with OpenSUSE Leap 15.x Date: Mon, 30 Jun 2025 23:34:56 +0200 Message-ID: X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 DCBCF241666; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=pM00unBi7oHbasvhE+Q0xgcQCRXVjGAelCsfM4F/6nqBpwpjovSJNF/dZpeAW77NsvzaVuAn5Qzg1svq6u/MlsbZOqquPJZJWZPlTYFMoiAeWnvN00DF/28vYbqVOggKEB8sKyq4MZ38kGS/4evDlj3YVwuexE7uX39zM75dKmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=ziyDRVvP7fisTUmklw0p9ITY4D1AfmB7FOFn6nzbObA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IpKF6vuaJWg8HB6wh88dkD8aNeRFKP1NtGUjc2Le+CuBPN9o6Hm+LH6RfnGBGKpoW7cR0lnkImlVXMgAM0FkSq3t/3GX98Y1FIFEpCpsDzLrz5bUZsYfUyuDOcXy1tqnP4d9PJXlI2ygo8fcH0sdQV/7U+A0XMqwmuXHG46/MSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=enprYEON; 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="enprYEON" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FA28C4CEF7; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=ziyDRVvP7fisTUmklw0p9ITY4D1AfmB7FOFn6nzbObA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=enprYEONABk6EFw4X0Tre9NFX1RQEVtkC6qH6dLcbyAJ5SOTZJR6uuL1hCnpFf/Vf 2c73Z66ntsRvjQfxYS62QGSn0cBrx7oy/1rchbBSM9aJZ7BxeT7/r3qIcpebKG+dMi PFIe0oFNFhaLkmFdeRiJVHDCzT8+3gpTy4F0s4WzRxsdwwhrH+jyKRBzGJlSue/Q5S i7FHxnsKnupJawFhAdEEDTrRxL6pJrt/vQhkFZ5qOnnQsK4SzIb2K0c/UxSo6nhMx2 /Z6gkBCWesKfrjhCqrAhK9API9c3usrEoZ4msVxyHVHAzLPosSvWYv9k+faXhGwTHH oRo3qRjl66g/Q== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWp-2Tj0; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 09/15] scripts: sphinx-pre-install.py fix opensuse hints Date: Mon, 30 Jun 2025 23:34:57 +0200 Message-ID: <4c782ff5825d5437041e9a30d91141e59ab092a0.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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" yaml hints arw wrong. 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 eca42d90ed01..69e2ea228df7 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -530,7 +530,7 @@ class SphinxDependencyChecker: "python-sphinx": "python3-sphinx", "virtualenv": "python3-virtualenv", "xelatex": "texlive-xetex-bin", - "yaml": "python3-pyyaml", + "yaml": "python3-pyyaml", # or python3-PyYAML? } =20 # On Tumbleweed, this package is also named rsvg-convert @@ -569,7 +569,7 @@ class SphinxDependencyChecker: progs.update({ "python-sphinx": "python311-Sphinx", "virtualenv": "python311-virtualenv", - "yaml": "python311-pyyaml", + "yaml": "python311-PyYAML", }) =20 # FIXME: add support for installing CJK fonts --=20 2.50.0 From nobody Wed Oct 8 07:40:05 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 082E424336D; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=pd2ZVQELzPMxpEYDSGPPamr09GwB3Enh8egoFSgTZXGxt32DOZaZM+dYE/e1vCayA+k0EJp3wvHdNTGYD8MoS3DSuCLy7ZAOR1NpXh5vZR5nRU+3eWQSOp6VgyHiqwFNBOkOn17YCn4Uui1S7IGSOrxFk6R8EViczh3QMneQpuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=75OOQGaZbWwBeHpHgcEDyXW9cfvWNPeCvA+D8R/RxPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H8BuS7jXTH1WW2KU4lPUjJA59tQhYoXeDzyzgth48r8f8PN1Icx+iLisxTPeI5vR8fr5LA1mEt+L6w/Domm5nYmYVuMhEUmuNJIP9317h7yc05kWBA0PPu366XuT/R70LApB4NzYix6ehmY/nyYwSJXg4KBhTXlBdEzSzPNt44o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s+zkYomk; 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="s+zkYomk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62480C4CEF6; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=75OOQGaZbWwBeHpHgcEDyXW9cfvWNPeCvA+D8R/RxPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s+zkYomkrCFMsF0i7McMY0ubkPdJHfHxPutOXSRMy33fs6Rp7P/vtQd4nc7zBOtse FrrIQ+JaCyanxALZ4h/lnsRXqkfsGsa9iTgAvSRD+K38igbYEMeJhjyz6lrA0kJKyf EHadADjOZ9zpVBpxq46VK0ULQ6rvMQdboW20XwDB4DsADzNnjJjAD7KNRX4t+CX+um FiAGXH+tmgDKPj1vTQCTuRULtSi8yhkjUJyF/buoKJuvjxMG6IySHz2Ry+BP6xPtwv EliJ54roooRcovAWwjl7h0f5h5x67Nh4CSC5IzkzvQyNx9xibWyHiqMgWyP8AerilO trzXbA8kbBuMA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWt-2aZH; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 10/15] scripts: sphinx-pre-install.py: fix support for gentoo Date: Mon, 30 Jun 2025 23:34:58 +0200 Message-ID: <228d90e53fe73f6e1ae218f26d0bbc0e0808e4c9.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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 enable 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 69e2ea228df7..9cbf548b0b9c 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -669,12 +669,13 @@ class SphinxDependencyChecker: =20 def give_gentoo_hints(self): progs =3D { - "convert": "media-gfx/imagemagick", - "dot": "media-gfx/graphviz", - "rsvg-convert": "gnome-base/librsvg", - "virtualenv": "dev-python/virtualenv", - "xelatex": "dev-texlive/texlive-xetex media-fonts/dejavu", - "yaml": "dev-python/pyyaml", + "convert": "media-gfx/imagemagick", + "dot": "media-gfx/graphviz", + "rsvg-convert": "gnome-base/librsvg", + "virtualenv": "dev-python/virtualenv", + "xelatex": "dev-texlive/texlive-xetex media-fonts/dejavu= ", + "yaml": "dev-python/pyyaml", + "python-sphinx": "dev-python/sphinx", } =20 if self.pdf: @@ -699,21 +700,17 @@ class SphinxDependencyChecker: print("You should run:") print("\n") =20 - imagemagick =3D "media-gfx/imagemagick svg png" - cairo =3D "media-gfx/graphviz cairo pdf" - portage_imagemagick =3D "/etc/portage/package.use/imagemagick" - portage_cairo =3D "/etc/portage/package.use/graphviz" =20 - result =3D self.run(["grep", "imagemagick", portage_imagemagick], - stdout=3Dsubprocess.PIPE, text=3DTrue) - if not result.stdout.strip(): - print(f"\tsudo su -c 'echo \"{imagemagick}\" > {portage_imagem= agick}'") + portages =3D [ + "media-gfx/imagemagick", + "media-gfx/graphviz", + ] =20 - result =3D self.run(["grep", "graphviz", portage_cairo], - stdout=3Dsubprocess.PIPE, text=3DTrue) - - if not result.stdout.strip(): - print(f"\tsudo su -c 'echo \"{cairo}\" > {portage_cairo}'") + for p in portages: + result =3D self.run(["grep", p, "/etc/portage/package.use/*"], + stdout=3Dsubprocess.PIPE, text=3DTrue) + if not result.stdout.strip(): + print(f"\tsudo emerge -av1 {p}") =20 print(f"\tsudo emerge --ask {self.install}") =20 --=20 2.50.0 From nobody Wed Oct 8 07:40:05 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 DCC39241671; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=iJkF1AfT/SHNSYszhJBA9tyq3XegipSW/dkylKVpN3s5iaVSTmoyxMnJKolijRH/pBUF3DgqwRt8fs/l7gvsEnTCCiiDi91Zo3a6gAGlItkexUKa3E/K2Jt8jYNnqJhblv/RGzLFlQnrUfV3Kfk/LXgKsk1cDLvu3eP/kOAFh+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=NXRybsGIFDCGU4Lr+9EFPMUtfdXp93JNctJg3aAfuAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JNIcG0Q+5Z7Pi9XmsRpoQGNvKCbXsfEv9qNLP3u0y6COypxKk8cVo+r0M9IychHgwrdTPvXUimXQ+2h8z6Ga/VnPQBboRlbGkYMn1sjByQzn6dsoAtnaJRcvjXCIPFENez6mLIwbEZ24TmEoa9Zgfyb2YmCO9+oVfYYWyfxFM44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dPWCaZOT; 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="dPWCaZOT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6477FC4CEF8; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=NXRybsGIFDCGU4Lr+9EFPMUtfdXp93JNctJg3aAfuAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPWCaZOTbkeZIEyX5OiYZSgZzfCubPGKWGFalmkmx0MnlgAzUVxH9wIKJ8n44N44Y S131rQ0wp/sqLKEYBHJSgH6k1uFbjCanMGkl9j3Wa9Hir9YVh/Bj8eHN7NifHTUW9J KE5zYQbbEL6Mc7SEoDxDPc9XNCbsvfdqk/0cMH8Re5qd721e5494ieIBt7Eqeg/1eI TL9qMTLNHgPtDSO415j2daKCwfuDRuKddw13myeiVsdgfdvbjClvmGdolT0YPQlI5R r6gpiPVfu3ZXxycvG3C2IgaRUVSnQHx3zSaz79gqUS8lPYf0+OVTI2zGI1n1OqFF2J oVbGwYVnDZdDA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QWx-2hKb; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 11/15] scripts: sphinx-pre-install: Address issues with OpenSUSE Tumbleweed Date: Mon, 30 Jun 2025 23:34:59 +0200 Message-ID: <4e89bf16dfd2be1e6c6c827a92bec1dc80c24774.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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 9cbf548b0b9c..72ac64f4e60b 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -571,6 +571,14 @@ class SphinxDependencyChecker: "virtualenv": "python311-virtualenv", "yaml": "python311-PyYAML", }) + else: + # Tumbleweed defaults to Python 3.11 + + progs.update({ + "python-sphinx": "python313-Sphinx", + "virtualenv": "python313-virtualenv", + "yaml": "python313-PyYAML", + }) =20 # FIXME: add support for installing CJK fonts # --=20 2.50.0 From nobody Wed Oct 8 07:40:05 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 DCB2E23FC52; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=uUvzqDGF5dURJvlzT8WKW7KNq+pSfoI60NOZUtsXAQCwBnAQf5K4hckZfObXwHRtqbhMzoO92JFuOPz5Hjb+pEtbHz8CcoJSaXVM0TLGgNJZ7SOfn0yQZN5JZmhKsDsJIElVy28RoTw1IVTp+EDWysMj06eWPXksqsTOa701tsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=opVgBgT8dUB2rKMoJmr5ql39zyKCEDajhIcychKj90Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TaDyeFhhJQ0hRijCYS6FPDqNlPg+fadB4XISeXR604AVy3DGqh3SzVX8CfzvmQErv9lxpv8aWeMlAaXLxnB0B9E6drgoSjvcN5r1vr1CcsDnbtuwb1IUJIMb6/Cp+vKnf0FG8SbdR5CwYoh0VXZ051A3izU+209Z49iPKYW+qPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M54MRKdg; 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="M54MRKdg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 678ACC4CEFA; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=opVgBgT8dUB2rKMoJmr5ql39zyKCEDajhIcychKj90Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M54MRKdgzBE7o7NDp+HtM5uY1cdWGJoUCggY/rYnFHkY8I4KkWrvWM0faVgsQZDlK ZryQ78AP70HsHx7w0opBxen5ogU0fouVqJip4bgew36oaDNI4t2EYO09dn22p13U8M PBAwAPP2I/pvTz90FyUoBCIH5q0Xn6kl8u2kx7E0tyikNkM9hfgzsyEvTZ9OdttPVv kOUdtsdfTkdHxMTvOiN6A+sb+UFlp/MEY1lNWrZvXlgEPJLxy7QljV035ZcPrAlucE z0/bc8watVcgZcZWUf6PKir3WQ8PNMC1G7WHvjSmPy1JMFA+zvgtnKM8ko1ssk0n6n UEEnk1e7Dwstg== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QX1-2o3Z; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 12/15] scripts: sphinx-pre-install.py: only show portage hints once Date: Mon, 30 Jun 2025 23:35:00 +0200 Message-ID: <299b4dedbfc9b43d734832e8366288b79edae358.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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 72ac64f4e60b..a941eae17a9e 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -89,6 +89,9 @@ class SphinxDependencyChecker: self.python_cmd =3D "" self.activate_cmd =3D "" =20 + # Certain hints are meant to be shown only once + self.first_hint =3D True + self.min_version =3D (0, 0, 0) self.cur_version =3D (0, 0, 0) self.latest_avail_ver =3D (0, 0, 0) @@ -714,11 +717,14 @@ class SphinxDependencyChecker: "media-gfx/graphviz", ] =20 - for p in portages: - result =3D self.run(["grep", p, "/etc/portage/package.use/*"], - stdout=3Dsubprocess.PIPE, text=3DTrue) - if not result.stdout.strip(): - print(f"\tsudo emerge -av1 {p}") + if self.first_hint: + for p in portages: + result =3D self.run(["grep", p, "/etc/portage/package.use/= *"], + stdout=3Dsubprocess.PIPE, text=3DTrue) + if not result.stdout.strip(): + print(f"\tsudo emerge -av1 {p}") + + self.first_hint =3D False =20 print(f"\tsudo emerge --ask {self.install}") =20 --=20 2.50.0 From nobody Wed Oct 8 07:40:05 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 05278242D8F; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=aZXyUW+u3P1ROELfJkpjEjM5nmLb7XwUEVtuHVSVyL93yaPdGuGGCyaet2vkfctLkqc9uKc2JFHXz4xQ/aV1wXnhdrqdqCw2i5287sBd2SwafX+cHebmu+xIwwyXAI0wIRkhD72QVz5ebSh9loAptmKBwwY5Z9szj3kCVmI3zW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=Ygtsq+De4GW5sas3J8PyjFBax+Pkg5M1g2qs8BnKYFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fN73d8Fdjx0Xm6YoPfjTauE4W6/mR5pYiU33/xAp9VaDhmh0WEG+SiSft0IHhQmT+Pq2pPGQkSpQWeiDctIFsTUHqnbO9mlEPaQF8D/VjJqFl1/dUzWTKUPVHoyQxQw6uuTuceoXLIt1AqM6fmp2MfLU3yOHk+1x7s5HJJSZRsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lZ/aDM/g; 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="lZ/aDM/g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DFF4C4CEFC; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=Ygtsq+De4GW5sas3J8PyjFBax+Pkg5M1g2qs8BnKYFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lZ/aDM/gEQHlykyeQunFAOnvgm2VsQEJMctRRiRa13N1U7VAIgPpPAGd+ckwPRTKl RiuHHlr3h8mItnI/6tm6xT/S4nGopZ0XaGdq5X4EyZj0qDCnLXF25JPDe5C2Y0Va3g Q8saZ0A3nSfx5ZLq4rpBP3ZO9jOEArGNeNZvhxKTHOBQIBwWC9sulpfdpbJK27dgsZ abH+Zv92y5cfaGZGyWxcuQpEDHvGz3SvTGCLzXwkIu1ieD+IBHI7tZhJD6IOhN2ea3 yd4iI1ZzNn4bc+zMzpwak65Rje7e8vqi7Def8X1zsOW+XqUQjDwzkiEMSABqB+rPCc L7tSPGRROHFiw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QX5-2ulK; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 13/15] scripts: sphinx-pre-install.py: cleanup rhel support Date: Mon, 30 Jun 2025 23:35:01 +0200 Message-ID: X-Mailer: git-send-email 2.50.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 a941eae17a9e..50413b7d2f2c 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -487,15 +487,31 @@ class SphinxDependencyChecker: =20 progs["virtualenv"] =3D "python-virtualenv" =20 - if rel and rel < 8: + if not rel or rel < 8: old =3D 1 self.pdf =3D False =20 - # RHEL 7 is in ELS, currently up to Jun, 2026 + print("ERROR: Distro not supported. Too old?") + return + + # TODO: check if RHEL8 still works. + # On my tests with docker "redhat/ubi8" image, there's no + # python3-sphinx (or similar) package. It comes with Python 3.= 6, + # but there are other python packages over there, so it may be + # possible to work with venv. + + if self.first_hint: + print("Note: RHEL-based distros typically require extra re= positories.\n" \ + "For most, enabling epel and crb are enough:\n" \ + "\tsudo dnf install -y epel-release", \ + "\tsudo dnf config-manager --set-enabled crb\n" \ + "Yet, some may have other required repositories. Tho= se commands could be useful:" \ + "\tsudo dnf repolist all" \ + "\tsudo repoquery --available --info ", + "\tsudo dnf config-manager --set-enabled '*' # enabl= e all - probably not what you want") + + self.first_hint =3D False =20 - print("Note: texlive packages on RHEL/CENTOS <=3D 7 are in= complete. Can't support PDF output") - print("If you want to build PDF, please read:") - print("\thttps://www.systutorials.com/241660/how-to-instal= l-tex-live-on-centos-7-linux/") =20 if self.pdf: pdf_pkgs =3D [ --=20 2.50.0 From nobody Wed Oct 8 07:40:05 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 06B8C242D93; Mon, 30 Jun 2025 21:52:44 +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=1751320365; cv=none; b=GqdoWMt2TJS4MrkGS3W6hB+gfnd6OkIsTiG9dZNEtWGwEY8BUJ9t69yZn+mT4LhQdvTmCK72M010Ev0YaUyTYXPXQo0rDpGvAKBT/60Aql8RXCMDGyb75q/65400liAA7c8yx5FxI/fceT/Pr55wKIABJeRWxTc62TLSxzTdy1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=klFInMyMuyuTpAHmohUw1L/ykD0tdIFslFtkTRkiwWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YpBT6USzDWqwWeyoh65/6zUqWlfjE9Uz3fsWuA5Abn3Rhhh3AaUmUj2mpBsTuZyvPicPSnImFgev8TFRNtHcsltSCi9Z84a1Jeu+tZ8sk7NTCzvGmm69tOdbjLTTKQFziyCm6hfMOTrohY1tiqUkhW55YfRIFoLTPjPCtuyjpbw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nogtk7Au; 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="nogtk7Au" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71B25C4CEFE; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=klFInMyMuyuTpAHmohUw1L/ykD0tdIFslFtkTRkiwWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nogtk7AumGtIlLzpISDJom9kpWJ1jKR2T0xxAG9CyHydMJ715WhehUmAHPrOrH8i3 j5fHuWn2DA0FlQZHCSca2oikq7I48SQ8R+qKinagBF5hfYPth7/XtcDHTmKsun8Mn0 SNld8GOqUin+kAG9x4EY1zR0UlaJ00el/xViZ7kmcpzm+XyvXicOr9LS2u9J9MU4Ok 3JdHNtcLRNUJ+pfDbcS3d8p3Y18d/cKlj6bFnUYXLDQ/wfOL5yXOKGMOW6undZQ1va o7GD5LnPqrIOxVkiaPPfs/905OEsnVzWOaZBO+TYJ6jdpcygGF1wBLMDF8RL8E+XDY R1G0tu6Ars4Ow== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QX9-31Yn; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 14/15] docs: Makefile: switch to the new scripts/sphinx-pre-install.py Date: Mon, 30 Jun 2025 23:35:02 +0200 Message-ID: <2528a42b09a5bc955ff506dc91500d268bcf7eca.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0 From nobody Wed Oct 8 07:40:05 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 3824B246762; Mon, 30 Jun 2025 21:52:45 +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=1751320365; cv=none; b=em2uR4vyaNjsc5Mn1gW+y6u55301x3Ye/1eKfhQWPVgT3s60ac3D0M9AorlqXjzcZPR2drLVvXMUJxGh9VpdBHvmQDY7IbhGkxeN2PDPGsn6MX7b5Ri0Whn3FZLmamU9kP4OTTuwYOZxwX3Gu2e913EoX+bOgMyCEYnSxP6yNkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751320365; c=relaxed/simple; bh=ip+nnSbMIGXLovZLXwh6F+qN07UsgWOqp8skAdjuWso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WW5znvC80Pi3fKV/s6mGkU3QiN7+Y5o4uY8EU0gE/uK+FC9ecxZRCibu4bkPwYUODr8aJcBF3XCywdliIHaLqA+tClLO9YoO+rMvMdeZhfoibthMqFePwdiAzfZfvmYHM+jjPk/XNrvTXr9IwjoloAOJNVO4+JI9omVUIQviPYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MIKyqPU3; 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="MIKyqPU3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78E79C116C6; Mon, 30 Jun 2025 21:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751320364; bh=ip+nnSbMIGXLovZLXwh6F+qN07UsgWOqp8skAdjuWso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIKyqPU3omeLBbq9kYIxlrvi/Rs3VU/vL88aorPvfwDkyDxfzqVk0oleLdz8w60O5 EfDwGU8OF1IlrZ2eO97gPWuZnacGO7FI6bLt0nUHOr1sRR46BVK9fdQPRlOVDeLK22 LzX9FMEse5xQEpZXksD2XJYA4JekCtW7/1DgMAposAuhodmWwkC9Sg9+cGOESd70XF AjzmkyNYz1kjPgtKNjOpmcLLU3HYwWu/BGmhvhe+GaXynSbaKwx7qwO45LumTK9504 PAuhDjBJM9Td21qVqLJqjj+LzhHSFwUs2VU7A60oooP9CyrlpTI8gEYyVbrYRmoHpM XAtP5SfLLONyw== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uWMQc-00000003QXD-38Wa; Mon, 30 Jun 2025 23:52:42 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Akira Yokosawa" , "Mauro Carvalho Chehab" , "Sai Vishnu M" , linux-kernel@vger.kernel.org Subject: [PATCH 15/15] scripts: sphinx-pre-install.pl: get rid of the old script Date: Mon, 30 Jun 2025 23:35:03 +0200 Message-ID: <8c720e26060f89128346c810a1061bc341cd56ce.1751318230.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.50.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.50.0