From nobody Sun Feb 8 22:00:25 2026 Received: from ms.lwn.net (ms.lwn.net [45.79.88.28]) (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 15E622D6605; Mon, 10 Nov 2025 22:04:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.79.88.28 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762812287; cv=none; b=oi/eJjYG0RRoTv3FT3hhuPHMXBqpzezQgJ7C2mfToJBPWav3v1C9o875Vm55WTbbtSohTjv35JWYkeBECKrHlKTsQcUAWIVZ3OJJw9S7He5ven1Y1a+3ER5IAH3VjDeMcSI8elBJyN7GhoaidV/J9LeAPnKpu2zg03eYaLZCIUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762812287; c=relaxed/simple; bh=Lbx9JmEmR09cc/ilz7Gv/CqdmqJZ8/Y8xhwqhQl2yys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U21g4tdn3UHXmsNjnNO+xJezIki6WWLAe1j78feKvq8lcinLdh47vULVLFGjk4Uyok+Xc+SskpMo3FfQT3SjZaPG22qu/tCmh9UevMTGTnNxSTakBE+PODvwnq6WilOAJvKZuHELzFAaMG8QAwEMEIeDG3zCer7t5CREnZwO+fw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lwn.net; spf=pass smtp.mailfrom=lwn.net; dkim=pass (2048-bit key) header.d=lwn.net header.i=@lwn.net header.b=LYBwJ6GX; arc=none smtp.client-ip=45.79.88.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lwn.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lwn.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lwn.net header.i=@lwn.net header.b="LYBwJ6GX" DKIM-Filter: OpenDKIM Filter v2.11.0 ms.lwn.net 1858D40C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lwn.net; s=20201203; t=1762812285; bh=MfTr2z0mo+rHbQuRrzQyznwn2KXS04ZCfpHQ2Wn6Ykc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYBwJ6GXJcyHdYheVjuclFc7WnxyuUhbHre0CDm7yRy80x251vtVBPDIhjJpo9D1K yBwGBCbZHN9DIAX+gUHSYT5qM0LQB1Z9tNiQOjnwNGb34gumlJNozLeAu4eq/RdP82 2CEKWRR3G3JcIY8KIUY2tVUr5r4DEcGjcNxEiHD/3MqOToZtubY4e0BH7E1obtgKhN 71deAzvEUupGt6BCV/SahogjJcpUl2A8mzxnRm8qMP6xXn5M+g/haFfA/2KwSwG0N0 Qw0ggwgVFQUCRXzTpc9Z4svrnKUAoHPu/ExYPRo4NaR6lj+cF7SH22oOgwuo/Wsgi/ XCc6Om0rhlJeQ== Received: from trenco.lwn.net (unknown [IPv6:2601:280:4600:2da9::1fe]) by ms.lwn.net (Postfix) with ESMTPA id 1858D40C39; Mon, 10 Nov 2025 22:04:45 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Akira Yokosawa , Jani Nikula , Jonathan Corbet Subject: [PATCH 1/2] docs: Move the python libraries to tools/lib/python Date: Mon, 10 Nov 2025 15:04:29 -0700 Message-ID: <20251110220430.726665-2-corbet@lwn.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251110220430.726665-1-corbet@lwn.net> References: <20251110220430.726665-1-corbet@lwn.net> 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 Content-Type: text/plain; charset="utf-8" "scripts/lib" was always a bit of an awkward place for Python modules. We already have tools/lib; create a tools/lib/python, move the libraries there, and update the users accordingly. While at it, move the contents of tools/docs/lib. Rather than make another directory, just put these documentation-oriented modules under "kdoc". Signed-off-by: Jonathan Corbet --- .pylintrc | 2 +- Documentation/Makefile | 2 +- Documentation/sphinx/kernel_abi.py | 2 +- Documentation/sphinx/kernel_include.py | 2 +- Documentation/sphinx/kerneldoc.py | 2 +- MAINTAINERS | 3 +-- scripts/jobserver-exec | 2 +- scripts/kernel-doc.py | 2 +- tools/docs/check-variable-fonts.py | 8 ++++++-- tools/docs/get_abi.py | 2 +- tools/docs/lib/__init__.py | 0 tools/docs/parse-headers.py | 9 ++++++--- tools/docs/sphinx-build-wrapper | 7 ++++--- tools/docs/sphinx-pre-install | 5 ++++- {scripts/lib =3D> tools/lib/python}/abi/abi_parser.py | 0 {scripts/lib =3D> tools/lib/python}/abi/abi_regex.py | 0 {scripts/lib =3D> tools/lib/python}/abi/helpers.py | 0 {scripts/lib =3D> tools/lib/python}/abi/system_symbols.py | 0 {scripts/lib =3D> tools/lib/python}/jobserver.py | 0 tools/{docs/lib =3D> lib/python/kdoc}/enrich_formatter.py | 0 {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_files.py | 0 {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_item.py | 0 {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_output.py | 0 {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_parser.py | 0 {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_re.py | 0 tools/{docs/lib =3D> lib/python/kdoc}/latex_fonts.py | 0 .../{docs/lib =3D> lib/python/kdoc}/parse_data_structs.py | 0 tools/{docs/lib =3D> lib/python/kdoc}/python_version.py | 0 28 files changed, 29 insertions(+), 19 deletions(-) delete mode 100644 tools/docs/lib/__init__.py rename {scripts/lib =3D> tools/lib/python}/abi/abi_parser.py (100%) rename {scripts/lib =3D> tools/lib/python}/abi/abi_regex.py (100%) rename {scripts/lib =3D> tools/lib/python}/abi/helpers.py (100%) rename {scripts/lib =3D> tools/lib/python}/abi/system_symbols.py (100%) rename {scripts/lib =3D> tools/lib/python}/jobserver.py (100%) rename tools/{docs/lib =3D> lib/python/kdoc}/enrich_formatter.py (100%) rename {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_files.py (100%) rename {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_item.py (100%) rename {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_output.py (100%) rename {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_parser.py (100%) rename {scripts/lib =3D> tools/lib/python}/kdoc/kdoc_re.py (100%) rename tools/{docs/lib =3D> lib/python/kdoc}/latex_fonts.py (100%) rename tools/{docs/lib =3D> lib/python/kdoc}/parse_data_structs.py (100%) rename tools/{docs/lib =3D> lib/python/kdoc}/python_version.py (100%) diff --git a/.pylintrc b/.pylintrc index 89eaf2100edd..8c6fc2b628b3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,2 +1,2 @@ [MASTER] -init-hook=3D'import sys; sys.path +=3D ["scripts/lib/kdoc", "scripts/lib/a= bi", "tools/docs/lib"]' +init-hook=3D'import sys; sys.path +=3D ["tools/lib/python"]' diff --git a/Documentation/Makefile b/Documentation/Makefile index d514ab6761dc..69aee1cb1f74 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -113,6 +113,6 @@ dochelp: @echo ' make PAPER=3D{a4|letter} Specifies the paper size used for LaTe= X/PDF output.' @echo @echo ' make FONTS_CONF_DENY_VF=3D{path} sets a deny list to block vari= able Noto CJK fonts' - @echo ' for PDF build. See tools/docs/lib/latex_fonts.py for more detai= ls' + @echo ' for PDF build. See tools/lib/python/kdoc/latex_fonts.py for mor= e details' @echo @echo ' Default location for the generated documents is Documentation/o= utput' diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 32e39fb8bc3b..7ec832da8444 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -43,7 +43,7 @@ from sphinx.util.docutils import switch_source_input from sphinx.util import logging =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "scripts/lib/abi")) +sys.path.insert(0, os.path.join(srctree, "tools/lib/python/abi")) =20 from abi_parser import AbiParser =20 diff --git a/Documentation/sphinx/kernel_include.py b/Documentation/sphinx/= kernel_include.py index 75e139287d50..a12455daa6d7 100755 --- a/Documentation/sphinx/kernel_include.py +++ b/Documentation/sphinx/kernel_include.py @@ -97,7 +97,7 @@ from docutils.parsers.rst.directives.body import CodeBloc= k, NumberLines from sphinx.util import logging =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "tools/docs/lib")) +sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc")) =20 from parse_data_structs import ParseDataStructs =20 diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerne= ldoc.py index 2586b4d4e494..56f382a6bdf1 100644 --- a/Documentation/sphinx/kerneldoc.py +++ b/Documentation/sphinx/kerneldoc.py @@ -42,7 +42,7 @@ from sphinx.util import logging from pprint import pformat =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "scripts/lib/kdoc")) +sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc")) =20 from kdoc_files import KernelFiles from kdoc_output import RestFormat diff --git a/MAINTAINERS b/MAINTAINERS index 8a9411e5c1e1..efe98e680c14 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7412,8 +7412,7 @@ P: Documentation/doc-guide/maintainer-profile.rst T: git git://git.lwn.net/linux.git docs-next F: Documentation/ F: scripts/kernel-doc* -F: scripts/lib/abi/* -F: scripts/lib/kdoc/* +F: tools/lib/python/* F: tools/docs/ F: tools/net/ynl/pyynl/lib/doc_generator.py X: Documentation/ABI/ diff --git a/scripts/jobserver-exec b/scripts/jobserver-exec index ae23afd344ec..758e947a6fb9 100755 --- a/scripts/jobserver-exec +++ b/scripts/jobserver-exec @@ -13,7 +13,7 @@ See: import os import sys =20 -LIB_DIR =3D "lib" +LIB_DIR =3D "../tools/lib/python" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py index d9fe2bcbd39c..bb24bbf73167 100755 --- a/scripts/kernel-doc.py +++ b/scripts/kernel-doc.py @@ -111,7 +111,7 @@ import sys =20 # Import Python modules =20 -LIB_DIR =3D "lib/kdoc" +LIB_DIR =3D "../tools/lib/python/kdoc" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) diff --git a/tools/docs/check-variable-fonts.py b/tools/docs/check-variable= -fonts.py index c0997d6861dc..c48bb05dad82 100755 --- a/tools/docs/check-variable-fonts.py +++ b/tools/docs/check-variable-fonts.py @@ -9,13 +9,17 @@ """ Detect problematic Noto CJK variable fonts. =20 -or more details, see lib/latex_fonts.py. +or more details, see .../tools/lib/python/kdoc/latex_fonts.py. """ =20 import argparse import sys +import os.path =20 -from lib.latex_fonts import LatexFontChecker +src_dir =3D os.path.dirname(os.path.realpath(__file__)) +sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) + +from latex_fonts import LatexFontChecker =20 checker =3D LatexFontChecker() =20 diff --git a/tools/docs/get_abi.py b/tools/docs/get_abi.py index da69e77559cc..e0abfe12fac7 100755 --- a/tools/docs/get_abi.py +++ b/tools/docs/get_abi.py @@ -14,7 +14,7 @@ import sys =20 # Import Python modules =20 -LIB_DIR =3D "../../scripts/lib/abi" +LIB_DIR =3D "../lib/python/abi" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) diff --git a/tools/docs/lib/__init__.py b/tools/docs/lib/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/tools/docs/parse-headers.py b/tools/docs/parse-headers.py index 6716c7300258..ed9cf2bf22de 100755 --- a/tools/docs/parse-headers.py +++ b/tools/docs/parse-headers.py @@ -24,10 +24,13 @@ The optional ``FILE_RULES`` contains a set of rules lik= e: replace define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ :c:type:`v4l2_event_mot= ion_det` """ =20 -import argparse +import argparse, sys +import os.path =20 -from lib.parse_data_structs import ParseDataStructs -from lib.enrich_formatter import EnrichFormatter +src_dir =3D os.path.dirname(os.path.realpath(__file__)) +sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) +from parse_data_structs import ParseDataStructs +from enrich_formatter import EnrichFormatter =20 def main(): """Main function""" diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrap= per index 1efaca3d16aa..ce0b1b5292da 100755 --- a/tools/docs/sphinx-build-wrapper +++ b/tools/docs/sphinx-build-wrapper @@ -56,14 +56,15 @@ import sys from concurrent import futures from glob import glob =20 -from lib.python_version import PythonVersion -from lib.latex_fonts import LatexFontChecker =20 -LIB_DIR =3D "../../scripts/lib" +LIB_DIR =3D "../lib/python" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) +sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR + '/kdoc')) # temporary =20 +from python_version import PythonVersion +from latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=3DC0413,C041= 1,E0401 =20 # diff --git a/tools/docs/sphinx-pre-install b/tools/docs/sphinx-pre-install index 647e1f60357f..d8c9fb76948d 100755 --- a/tools/docs/sphinx-pre-install +++ b/tools/docs/sphinx-pre-install @@ -32,8 +32,11 @@ import re import subprocess import sys from glob import glob +import os.path =20 -from lib.python_version import PythonVersion +src_dir =3D os.path.dirname(os.path.realpath(__file__)) +sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) +from python_version import PythonVersion =20 RECOMMENDED_VERSION =3D PythonVersion("3.4.3").version MIN_PYTHON_VERSION =3D PythonVersion("3.7").version diff --git a/scripts/lib/abi/abi_parser.py b/tools/lib/python/abi/abi_parse= r.py similarity index 100% rename from scripts/lib/abi/abi_parser.py rename to tools/lib/python/abi/abi_parser.py diff --git a/scripts/lib/abi/abi_regex.py b/tools/lib/python/abi/abi_regex.= py similarity index 100% rename from scripts/lib/abi/abi_regex.py rename to tools/lib/python/abi/abi_regex.py diff --git a/scripts/lib/abi/helpers.py b/tools/lib/python/abi/helpers.py similarity index 100% rename from scripts/lib/abi/helpers.py rename to tools/lib/python/abi/helpers.py diff --git a/scripts/lib/abi/system_symbols.py b/tools/lib/python/abi/syste= m_symbols.py similarity index 100% rename from scripts/lib/abi/system_symbols.py rename to tools/lib/python/abi/system_symbols.py diff --git a/scripts/lib/jobserver.py b/tools/lib/python/jobserver.py similarity index 100% rename from scripts/lib/jobserver.py rename to tools/lib/python/jobserver.py diff --git a/tools/docs/lib/enrich_formatter.py b/tools/lib/python/kdoc/enr= ich_formatter.py similarity index 100% rename from tools/docs/lib/enrich_formatter.py rename to tools/lib/python/kdoc/enrich_formatter.py diff --git a/scripts/lib/kdoc/kdoc_files.py b/tools/lib/python/kdoc/kdoc_fi= les.py similarity index 100% rename from scripts/lib/kdoc/kdoc_files.py rename to tools/lib/python/kdoc/kdoc_files.py diff --git a/scripts/lib/kdoc/kdoc_item.py b/tools/lib/python/kdoc/kdoc_ite= m.py similarity index 100% rename from scripts/lib/kdoc/kdoc_item.py rename to tools/lib/python/kdoc/kdoc_item.py diff --git a/scripts/lib/kdoc/kdoc_output.py b/tools/lib/python/kdoc/kdoc_o= utput.py similarity index 100% rename from scripts/lib/kdoc/kdoc_output.py rename to tools/lib/python/kdoc/kdoc_output.py diff --git a/scripts/lib/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_p= arser.py similarity index 100% rename from scripts/lib/kdoc/kdoc_parser.py rename to tools/lib/python/kdoc/kdoc_parser.py diff --git a/scripts/lib/kdoc/kdoc_re.py b/tools/lib/python/kdoc/kdoc_re.py similarity index 100% rename from scripts/lib/kdoc/kdoc_re.py rename to tools/lib/python/kdoc/kdoc_re.py diff --git a/tools/docs/lib/latex_fonts.py b/tools/lib/python/kdoc/latex_fo= nts.py similarity index 100% rename from tools/docs/lib/latex_fonts.py rename to tools/lib/python/kdoc/latex_fonts.py diff --git a/tools/docs/lib/parse_data_structs.py b/tools/lib/python/kdoc/p= arse_data_structs.py similarity index 100% rename from tools/docs/lib/parse_data_structs.py rename to tools/lib/python/kdoc/parse_data_structs.py diff --git a/tools/docs/lib/python_version.py b/tools/lib/python/kdoc/pytho= n_version.py similarity index 100% rename from tools/docs/lib/python_version.py rename to tools/lib/python/kdoc/python_version.py --=20 2.51.0 From nobody Sun Feb 8 22:00:25 2026 Received: from ms.lwn.net (ms.lwn.net [45.79.88.28]) (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 AA8CF273D81; Mon, 10 Nov 2025 22:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.79.88.28 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762812288; cv=none; b=l33KwvRiBXSzonoL+AJQsLBig8De0dJ26xZv05Da++g3QVVabAUTCvkNzdXGuZ1RvYR0mswLaTENgRwkIvh6XEpNrcyWarwv9BEr/36xpCDijn9bAO5JvNvQvQg4KH7RtiWuM3XHPEFWbZLXaOYqXhNWzzxOp6XpUHtayjluCzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762812288; c=relaxed/simple; bh=wi4eKj4SgGVKPEhjzHr8OhGZJBn2VGgibZO8T+gqAj8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ugMc3BonP7pGL+v8tH6bkBLfzAa2baJgwpNcUAYQOs3GackaNdJtBbsbVYx7I32YVYifSwrVwlcGcoyEPAjmgSQOar0EDSQz2F2WrYRRB3twXur9ydgTGbT6upTbJ2ed5TS/qiH7/t0isFOPrXQbObRBXA62Nd7KcaP37Snn8D0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lwn.net; spf=pass smtp.mailfrom=lwn.net; dkim=pass (2048-bit key) header.d=lwn.net header.i=@lwn.net header.b=Y/lO37/i; arc=none smtp.client-ip=45.79.88.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lwn.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lwn.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lwn.net header.i=@lwn.net header.b="Y/lO37/i" DKIM-Filter: OpenDKIM Filter v2.11.0 ms.lwn.net A908840C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lwn.net; s=20201203; t=1762812286; bh=ETTEAfV8AinSBTl/zGJPRd88A1tGp5WgYF+bJ+LN7vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/lO37/i5KiE23pXSDahGzCkVLRZFdBgVaDuEH2mvKljubtnmDwEbUXXhuBWMo68T RTw5uze/aeeJ3YAk17kQkpXkstqvJ0CDQsd0PrMEq7TNVrLHOS4Q4ZJEbLrfy89ZC7 fKqjPnkN73cT/3srrkTVLspMtJIs2KaN/q+zTlJeFkBUtSLwd+Lp6ZLZsEYbfjqNNM /UCsxTNhyChKVr6hZ0W3gfxoZT9ojCQSC3JB2zE7/qCG70WmiwEAoZ+EYgq88lrKnr 5L2MEwKSIKjZJ+ZbeVP4+yHGT85c4ZFjHwUHwKlHO1qFXiNz6VYB8X5EvUYKvsvROb IhUpHlFbsGGhQ== Received: from trenco.lwn.net (unknown [IPv6:2601:280:4600:2da9::1fe]) by ms.lwn.net (Postfix) with ESMTPA id A908840C3A; Mon, 10 Nov 2025 22:04:45 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Akira Yokosawa , Jani Nikula , Jonathan Corbet Subject: [PATCH 2/2] docs: bring some order to our Python module hierarchy Date: Mon, 10 Nov 2025 15:04:30 -0700 Message-ID: <20251110220430.726665-3-corbet@lwn.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251110220430.726665-1-corbet@lwn.net> References: <20251110220430.726665-1-corbet@lwn.net> 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 Content-Type: text/plain; charset="utf-8" Now that we have tools/lib/python for our Python modules, turn them into proper packages with a single namespace so that everything can just use tools/lib/python in sys.path. No functional change. Signed-off-by: Jonathan Corbet --- Documentation/sphinx/kernel_abi.py | 4 ++-- Documentation/sphinx/kernel_include.py | 4 ++-- Documentation/sphinx/kerneldoc.py | 6 +++--- scripts/kernel-doc.py | 6 +++--- tools/docs/check-variable-fonts.py | 4 ++-- tools/docs/get_abi.py | 10 +++++----- tools/docs/parse-headers.py | 6 +++--- tools/docs/sphinx-build-wrapper | 5 ++--- tools/docs/sphinx-pre-install | 4 ++-- tools/lib/python/__init__.py | 0 tools/lib/python/abi/__init__.py | 0 tools/lib/python/abi/abi_parser.py | 2 +- tools/lib/python/abi/abi_regex.py | 4 ++-- tools/lib/python/abi/system_symbols.py | 2 +- tools/lib/python/kdoc/__init__.py | 0 tools/lib/python/kdoc/kdoc_files.py | 4 ++-- tools/lib/python/kdoc/kdoc_output.py | 4 ++-- tools/lib/python/kdoc/kdoc_parser.py | 4 ++-- 18 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 tools/lib/python/__init__.py create mode 100644 tools/lib/python/abi/__init__.py create mode 100644 tools/lib/python/kdoc/__init__.py diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 7ec832da8444..5667f207d175 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -43,9 +43,9 @@ from sphinx.util.docutils import switch_source_input from sphinx.util import logging =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "tools/lib/python/abi")) +sys.path.insert(0, os.path.join(srctree, "tools/lib/python")) =20 -from abi_parser import AbiParser +from abi.abi_parser import AbiParser =20 __version__ =3D "1.0" =20 diff --git a/Documentation/sphinx/kernel_include.py b/Documentation/sphinx/= kernel_include.py index a12455daa6d7..626762ff6af3 100755 --- a/Documentation/sphinx/kernel_include.py +++ b/Documentation/sphinx/kernel_include.py @@ -97,9 +97,9 @@ from docutils.parsers.rst.directives.body import CodeBloc= k, NumberLines from sphinx.util import logging =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc")) +sys.path.insert(0, os.path.join(srctree, "tools/lib/python")) =20 -from parse_data_structs import ParseDataStructs +from kdoc.parse_data_structs import ParseDataStructs =20 __version__ =3D "1.0" logger =3D logging.getLogger(__name__) diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerne= ldoc.py index 56f382a6bdf1..d8cdf068ef35 100644 --- a/Documentation/sphinx/kerneldoc.py +++ b/Documentation/sphinx/kerneldoc.py @@ -42,10 +42,10 @@ from sphinx.util import logging from pprint import pformat =20 srctree =3D os.path.abspath(os.environ["srctree"]) -sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc")) +sys.path.insert(0, os.path.join(srctree, "tools/lib/python")) =20 -from kdoc_files import KernelFiles -from kdoc_output import RestFormat +from kdoc.kdoc_files import KernelFiles +from kdoc.kdoc_output import RestFormat =20 __version__ =3D '1.0' kfiles =3D None diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py index bb24bbf73167..7a1eaf986bcd 100755 --- a/scripts/kernel-doc.py +++ b/scripts/kernel-doc.py @@ -111,7 +111,7 @@ import sys =20 # Import Python modules =20 -LIB_DIR =3D "../tools/lib/python/kdoc" +LIB_DIR =3D "../tools/lib/python" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) @@ -292,8 +292,8 @@ def main(): logger.warning("Python 3.7 or later is required for correct result= s") =20 # Import kernel-doc libraries only after checking Python version - from kdoc_files import KernelFiles # pylint: disable= =3DC0415 - from kdoc_output import RestFormat, ManFormat # pylint: disable= =3DC0415 + from kdoc.kdoc_files import KernelFiles # pylint: disable= =3DC0415 + from kdoc.kdoc_output import RestFormat, ManFormat # pylint: disable= =3DC0415 =20 if args.man: out_style =3D ManFormat(modulename=3Dargs.modulename) diff --git a/tools/docs/check-variable-fonts.py b/tools/docs/check-variable= -fonts.py index c48bb05dad82..958d5a745724 100755 --- a/tools/docs/check-variable-fonts.py +++ b/tools/docs/check-variable-fonts.py @@ -17,9 +17,9 @@ import sys import os.path =20 src_dir =3D os.path.dirname(os.path.realpath(__file__)) -sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) +sys.path.insert(0, os.path.join(src_dir, '../lib/python')) =20 -from latex_fonts import LatexFontChecker +from kdoc.latex_fonts import LatexFontChecker =20 checker =3D LatexFontChecker() =20 diff --git a/tools/docs/get_abi.py b/tools/docs/get_abi.py index e0abfe12fac7..2f0b99401f26 100755 --- a/tools/docs/get_abi.py +++ b/tools/docs/get_abi.py @@ -14,15 +14,15 @@ import sys =20 # Import Python modules =20 -LIB_DIR =3D "../lib/python/abi" +LIB_DIR =3D "../lib/python" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) =20 -from abi_parser import AbiParser # pylint: disable=3DC0413 -from abi_regex import AbiRegex # pylint: disable=3DC0413 -from helpers import ABI_DIR, DEBUG_HELP # pylint: disable=3DC0413 -from system_symbols import SystemSymbols # pylint: disable=3DC0413 +from abi.abi_parser import AbiParser # pylint: disable=3DC0= 413 +from abi.abi_regex import AbiRegex # pylint: disable=3DC0= 413 +from abi.helpers import ABI_DIR, DEBUG_HELP # pylint: disable=3DC0= 413 +from abi.system_symbols import SystemSymbols # pylint: disable=3DC0= 413 =20 # Command line classes =20 diff --git a/tools/docs/parse-headers.py b/tools/docs/parse-headers.py index ed9cf2bf22de..436acea4c6ca 100755 --- a/tools/docs/parse-headers.py +++ b/tools/docs/parse-headers.py @@ -28,9 +28,9 @@ import argparse, sys import os.path =20 src_dir =3D os.path.dirname(os.path.realpath(__file__)) -sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) -from parse_data_structs import ParseDataStructs -from enrich_formatter import EnrichFormatter +sys.path.insert(0, os.path.join(src_dir, '../lib/python')) +from kdoc.parse_data_structs import ParseDataStructs +from kdoc.enrich_formatter import EnrichFormatter =20 def main(): """Main function""" diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrap= per index ce0b1b5292da..d4943d952e2a 100755 --- a/tools/docs/sphinx-build-wrapper +++ b/tools/docs/sphinx-build-wrapper @@ -61,10 +61,9 @@ LIB_DIR =3D "../lib/python" SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) =20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) -sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR + '/kdoc')) # temporary =20 -from python_version import PythonVersion -from latex_fonts import LatexFontChecker +from kdoc.python_version import PythonVersion +from kdoc.latex_fonts import LatexFontChecker from jobserver import JobserverExec # pylint: disable=3DC0413,C041= 1,E0401 =20 # diff --git a/tools/docs/sphinx-pre-install b/tools/docs/sphinx-pre-install index d8c9fb76948d..965c9b093a41 100755 --- a/tools/docs/sphinx-pre-install +++ b/tools/docs/sphinx-pre-install @@ -35,8 +35,8 @@ from glob import glob import os.path =20 src_dir =3D os.path.dirname(os.path.realpath(__file__)) -sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) -from python_version import PythonVersion +sys.path.insert(0, os.path.join(src_dir, '../lib/python')) +from kdoc.python_version import PythonVersion =20 RECOMMENDED_VERSION =3D PythonVersion("3.4.3").version MIN_PYTHON_VERSION =3D PythonVersion("3.7").version diff --git a/tools/lib/python/__init__.py b/tools/lib/python/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/lib/python/abi/__init__.py b/tools/lib/python/abi/__init= __.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/lib/python/abi/abi_parser.py b/tools/lib/python/abi/abi_= parser.py index 66a738013ce1..9b8db70067ef 100644 --- a/tools/lib/python/abi/abi_parser.py +++ b/tools/lib/python/abi/abi_parser.py @@ -17,7 +17,7 @@ from random import randrange, seed =20 # Import Python modules =20 -from helpers import AbiDebug, ABI_DIR +from abi.helpers import AbiDebug, ABI_DIR =20 =20 class AbiParser: diff --git a/tools/lib/python/abi/abi_regex.py b/tools/lib/python/abi/abi_r= egex.py index 8a57846cbc69..d5553206de3c 100644 --- a/tools/lib/python/abi/abi_regex.py +++ b/tools/lib/python/abi/abi_regex.py @@ -12,8 +12,8 @@ import sys =20 from pprint import pformat =20 -from abi_parser import AbiParser -from helpers import AbiDebug +from abi.abi_parser import AbiParser +from abi.helpers import AbiDebug =20 class AbiRegex(AbiParser): """Extends AbiParser to search ABI nodes with regular expressions""" diff --git a/tools/lib/python/abi/system_symbols.py b/tools/lib/python/abi/= system_symbols.py index f15c94a6e33c..4a2554da217b 100644 --- a/tools/lib/python/abi/system_symbols.py +++ b/tools/lib/python/abi/system_symbols.py @@ -15,7 +15,7 @@ from concurrent import futures from datetime import datetime from random import shuffle =20 -from helpers import AbiDebug +from abi.helpers import AbiDebug =20 class SystemSymbols: """Stores arguments for the class and initialize class vars""" diff --git a/tools/lib/python/kdoc/__init__.py b/tools/lib/python/kdoc/__in= it__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/lib/python/kdoc/kdoc_files.py b/tools/lib/python/kdoc/kd= oc_files.py index 061c033f32da..8170ab22e598 100644 --- a/tools/lib/python/kdoc/kdoc_files.py +++ b/tools/lib/python/kdoc/kdoc_files.py @@ -13,8 +13,8 @@ import logging import os import re =20 -from kdoc_parser import KernelDoc -from kdoc_output import OutputFormat +from kdoc.kdoc_parser import KernelDoc +from kdoc.kdoc_output import OutputFormat =20 =20 class GlobSourceFiles: diff --git a/tools/lib/python/kdoc/kdoc_output.py b/tools/lib/python/kdoc/k= doc_output.py index 58f115059e93..14378953301b 100644 --- a/tools/lib/python/kdoc/kdoc_output.py +++ b/tools/lib/python/kdoc/kdoc_output.py @@ -19,8 +19,8 @@ import os import re from datetime import datetime =20 -from kdoc_parser import KernelDoc, type_param -from kdoc_re import KernRe +from kdoc.kdoc_parser import KernelDoc, type_param +from kdoc.kdoc_re import KernRe =20 =20 function_pointer =3D KernRe(r"([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)", cache=3DF= alse) diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/k= doc_parser.py index f7dbb0868367..c0cc714d4d6f 100644 --- a/tools/lib/python/kdoc/kdoc_parser.py +++ b/tools/lib/python/kdoc/kdoc_parser.py @@ -16,8 +16,8 @@ import sys import re from pprint import pformat =20 -from kdoc_re import NestedMatch, KernRe -from kdoc_item import KdocItem +from kdoc.kdoc_re import NestedMatch, KernRe +from kdoc.kdoc_item import KdocItem =20 # # Regular expressions used to parse kernel-doc markups at KernelDoc class. --=20 2.51.0