linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Move Python modules to tools/lib/python
@ 2025-11-10 22:04 Jonathan Corbet
  2025-11-10 22:04 ` [PATCH 1/2] docs: Move the python libraries " Jonathan Corbet
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jonathan Corbet @ 2025-11-10 22:04 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-kernel, Mauro Carvalho Chehab, Akira Yokosawa, Jani Nikula,
	Jonathan Corbet

scripts/lib was always a bit of an awkward place for Python libraries; give
them a proper home under tools/lib/python.  Put the modules from
tools/docs/lib there for good measure.

The second patch ties them into a single package namespace.  It would be
more aesthetically pleasing to add a kernel layer, so we could say:

  from kernel.kdoc import kdoc_parser

...and have the kernel-specific stuff clearly marked, but that means adding
an empty directory in the hierarchy, which isn't as pleasing.

There are some other "Python library" directories hidden in the kernel
tree; we may eventually want to encourage them to move as well.

Jonathan Corbet (2):
  docs: Move the python libraries to tools/lib/python
  docs: bring some order to our Python module hierarchy

 .pylintrc                                              |  2 +-
 Documentation/Makefile                                 |  2 +-
 Documentation/sphinx/kernel_abi.py                     |  4 ++--
 Documentation/sphinx/kernel_include.py                 |  4 ++--
 Documentation/sphinx/kerneldoc.py                      |  6 +++---
 MAINTAINERS                                            |  3 +--
 scripts/jobserver-exec                                 |  2 +-
 scripts/kernel-doc.py                                  |  6 +++---
 tools/docs/check-variable-fonts.py                     |  8 ++++++--
 tools/docs/get_abi.py                                  | 10 +++++-----
 tools/docs/parse-headers.py                            |  9 ++++++---
 tools/docs/sphinx-build-wrapper                        |  6 +++---
 tools/docs/sphinx-pre-install                          |  5 ++++-
 tools/{docs/lib => lib/python}/__init__.py             |  0
 tools/lib/python/abi/__init__.py                       |  0
 {scripts/lib => tools/lib/python}/abi/abi_parser.py    |  2 +-
 {scripts/lib => tools/lib/python}/abi/abi_regex.py     |  4 ++--
 {scripts/lib => tools/lib/python}/abi/helpers.py       |  0
 .../lib => tools/lib/python}/abi/system_symbols.py     |  2 +-
 {scripts/lib => tools/lib/python}/jobserver.py         |  0
 tools/lib/python/kdoc/__init__.py                      |  0
 .../{docs/lib => lib/python/kdoc}/enrich_formatter.py  |  0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_files.py   |  4 ++--
 {scripts/lib => tools/lib/python}/kdoc/kdoc_item.py    |  0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_output.py  |  4 ++--
 {scripts/lib => tools/lib/python}/kdoc/kdoc_parser.py  |  4 ++--
 {scripts/lib => tools/lib/python}/kdoc/kdoc_re.py      |  0
 tools/{docs/lib => lib/python/kdoc}/latex_fonts.py     |  0
 .../lib => lib/python/kdoc}/parse_data_structs.py      |  0
 tools/{docs/lib => lib/python/kdoc}/python_version.py  |  0
 30 files changed, 48 insertions(+), 39 deletions(-)
 rename tools/{docs/lib => lib/python}/__init__.py (100%)
 create mode 100644 tools/lib/python/abi/__init__.py
 rename {scripts/lib => tools/lib/python}/abi/abi_parser.py (99%)
 rename {scripts/lib => tools/lib/python}/abi/abi_regex.py (99%)
 rename {scripts/lib => tools/lib/python}/abi/helpers.py (100%)
 rename {scripts/lib => tools/lib/python}/abi/system_symbols.py (99%)
 rename {scripts/lib => tools/lib/python}/jobserver.py (100%)
 create mode 100644 tools/lib/python/kdoc/__init__.py
 rename tools/{docs/lib => lib/python/kdoc}/enrich_formatter.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_files.py (99%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_item.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_output.py (99%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_parser.py (99%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_re.py (100%)
 rename tools/{docs/lib => lib/python/kdoc}/latex_fonts.py (100%)
 rename tools/{docs/lib => lib/python/kdoc}/parse_data_structs.py (100%)
 rename tools/{docs/lib => lib/python/kdoc}/python_version.py (100%)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] docs: Move the python libraries to tools/lib/python
  2025-11-10 22:04 [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
@ 2025-11-10 22:04 ` Jonathan Corbet
  2025-11-10 22:04 ` [PATCH 2/2] docs: bring some order to our Python module hierarchy Jonathan Corbet
  2025-11-18 16:27 ` [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
  2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Corbet @ 2025-11-10 22:04 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-kernel, Mauro Carvalho Chehab, Akira Yokosawa, Jani Nikula,
	Jonathan Corbet

"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 <corbet@lwn.net>
---
 .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 => tools/lib/python}/abi/abi_parser.py      | 0
 {scripts/lib => tools/lib/python}/abi/abi_regex.py       | 0
 {scripts/lib => tools/lib/python}/abi/helpers.py         | 0
 {scripts/lib => tools/lib/python}/abi/system_symbols.py  | 0
 {scripts/lib => tools/lib/python}/jobserver.py           | 0
 tools/{docs/lib => lib/python/kdoc}/enrich_formatter.py  | 0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_files.py     | 0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_item.py      | 0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_output.py    | 0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_parser.py    | 0
 {scripts/lib => tools/lib/python}/kdoc/kdoc_re.py        | 0
 tools/{docs/lib => lib/python/kdoc}/latex_fonts.py       | 0
 .../{docs/lib => lib/python/kdoc}/parse_data_structs.py  | 0
 tools/{docs/lib => 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 => tools/lib/python}/abi/abi_parser.py (100%)
 rename {scripts/lib => tools/lib/python}/abi/abi_regex.py (100%)
 rename {scripts/lib => tools/lib/python}/abi/helpers.py (100%)
 rename {scripts/lib => tools/lib/python}/abi/system_symbols.py (100%)
 rename {scripts/lib => tools/lib/python}/jobserver.py (100%)
 rename tools/{docs/lib => lib/python/kdoc}/enrich_formatter.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_files.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_item.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_output.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_parser.py (100%)
 rename {scripts/lib => tools/lib/python}/kdoc/kdoc_re.py (100%)
 rename tools/{docs/lib => lib/python/kdoc}/latex_fonts.py (100%)
 rename tools/{docs/lib => lib/python/kdoc}/parse_data_structs.py (100%)
 rename tools/{docs/lib => 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='import sys; sys.path += ["scripts/lib/kdoc", "scripts/lib/abi", "tools/docs/lib"]'
+init-hook='import sys; sys.path += ["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={a4|letter} Specifies the paper size used for LaTeX/PDF output.'
 	@echo
 	@echo  '  make FONTS_CONF_DENY_VF={path} sets a deny list to block variable Noto CJK fonts'
-	@echo  '  for PDF build. See tools/docs/lib/latex_fonts.py for more details'
+	@echo  '  for PDF build. See tools/lib/python/kdoc/latex_fonts.py for more details'
 	@echo
 	@echo  '  Default location for the generated documents is Documentation/output'
diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_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
 
 srctree = 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"))
 
 from abi_parser import AbiParser
 
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 CodeBlock, NumberLines
 from sphinx.util import logging
 
 srctree = 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"))
 
 from parse_data_structs import ParseDataStructs
 
diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.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
 
 srctree = 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"))
 
 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
 
-LIB_DIR = "lib"
+LIB_DIR = "../tools/lib/python"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 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
 
 # Import Python modules
 
-LIB_DIR = "lib/kdoc"
+LIB_DIR = "../tools/lib/python/kdoc"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 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.
 
-or more details, see lib/latex_fonts.py.
+or more details, see .../tools/lib/python/kdoc/latex_fonts.py.
 """
 
 import argparse
 import sys
+import os.path
 
-from lib.latex_fonts import LatexFontChecker
+src_dir = os.path.dirname(os.path.realpath(__file__))
+sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc'))
+
+from latex_fonts import LatexFontChecker
 
 checker = LatexFontChecker()
 
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
 
 # Import Python modules
 
-LIB_DIR = "../../scripts/lib/abi"
+LIB_DIR = "../lib/python/abi"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 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 like:
     replace define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ :c:type:`v4l2_event_motion_det`
 """
 
-import argparse
+import argparse, sys
+import os.path
 
-from lib.parse_data_structs import ParseDataStructs
-from lib.enrich_formatter import EnrichFormatter
+src_dir = 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
 
 def main():
     """Main function"""
diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrapper
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
 
-from lib.python_version import PythonVersion
-from lib.latex_fonts import LatexFontChecker
 
-LIB_DIR = "../../scripts/lib"
+LIB_DIR = "../lib/python"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
+sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR + '/kdoc'))  # temporary
 
+from python_version import PythonVersion
+from latex_fonts import LatexFontChecker
 from jobserver import JobserverExec         # pylint: disable=C0413,C0411,E0401
 
 #
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
 
-from lib.python_version import PythonVersion
+src_dir = os.path.dirname(os.path.realpath(__file__))
+sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc'))
+from python_version import PythonVersion
 
 RECOMMENDED_VERSION = PythonVersion("3.4.3").version
 MIN_PYTHON_VERSION = PythonVersion("3.7").version
diff --git a/scripts/lib/abi/abi_parser.py b/tools/lib/python/abi/abi_parser.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/system_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/enrich_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_files.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_item.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_output.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_parser.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_fonts.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/parse_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/python_version.py
similarity index 100%
rename from tools/docs/lib/python_version.py
rename to tools/lib/python/kdoc/python_version.py
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] docs: bring some order to our Python module hierarchy
  2025-11-10 22:04 [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
  2025-11-10 22:04 ` [PATCH 1/2] docs: Move the python libraries " Jonathan Corbet
@ 2025-11-10 22:04 ` Jonathan Corbet
  2025-11-18 16:27 ` [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
  2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Corbet @ 2025-11-10 22:04 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-kernel, Mauro Carvalho Chehab, Akira Yokosawa, Jani Nikula,
	Jonathan Corbet

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 <corbet@lwn.net>
---
 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/kernel_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
 
 srctree = 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"))
 
-from abi_parser import AbiParser
+from abi.abi_parser import AbiParser
 
 __version__ = "1.0"
 
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 CodeBlock, NumberLines
 from sphinx.util import logging
 
 srctree = 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"))
 
-from parse_data_structs import ParseDataStructs
+from kdoc.parse_data_structs import ParseDataStructs
 
 __version__ = "1.0"
 logger = logging.getLogger(__name__)
diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.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
 
 srctree = 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"))
 
-from kdoc_files import KernelFiles
-from kdoc_output import RestFormat
+from kdoc.kdoc_files import KernelFiles
+from kdoc.kdoc_output import RestFormat
 
 __version__  = '1.0'
 kfiles = 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
 
 # Import Python modules
 
-LIB_DIR = "../tools/lib/python/kdoc"
+LIB_DIR = "../tools/lib/python"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 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 results")
 
     # Import kernel-doc libraries only after checking Python version
-    from kdoc_files import KernelFiles                  # pylint: disable=C0415
-    from kdoc_output import RestFormat, ManFormat       # pylint: disable=C0415
+    from kdoc.kdoc_files import KernelFiles             # pylint: disable=C0415
+    from kdoc.kdoc_output import RestFormat, ManFormat  # pylint: disable=C0415
 
     if args.man:
         out_style = ManFormat(modulename=args.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
 
 src_dir = 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'))
 
-from latex_fonts import LatexFontChecker
+from kdoc.latex_fonts import LatexFontChecker
 
 checker = LatexFontChecker()
 
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
 
 # Import Python modules
 
-LIB_DIR = "../lib/python/abi"
+LIB_DIR = "../lib/python"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
 
-from abi_parser import AbiParser                # pylint: disable=C0413
-from abi_regex import AbiRegex                  # pylint: disable=C0413
-from helpers import ABI_DIR, DEBUG_HELP         # pylint: disable=C0413
-from system_symbols import SystemSymbols        # pylint: disable=C0413
+from abi.abi_parser import AbiParser                # pylint: disable=C0413
+from abi.abi_regex import AbiRegex                  # pylint: disable=C0413
+from abi.helpers import ABI_DIR, DEBUG_HELP         # pylint: disable=C0413
+from abi.system_symbols import SystemSymbols        # pylint: disable=C0413
 
 # Command line classes
 
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
 
 src_dir = 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
 
 def main():
     """Main function"""
diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrapper
index ce0b1b5292da..d4943d952e2a 100755
--- a/tools/docs/sphinx-build-wrapper
+++ b/tools/docs/sphinx-build-wrapper
@@ -61,10 +61,9 @@ LIB_DIR = "../lib/python"
 SRC_DIR = os.path.dirname(os.path.realpath(__file__))
 
 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
-sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR + '/kdoc'))  # temporary
 
-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=C0413,C0411,E0401
 
 #
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
 
 src_dir = 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
 
 RECOMMENDED_VERSION = PythonVersion("3.4.3").version
 MIN_PYTHON_VERSION = 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
 
 # Import Python modules
 
-from helpers import AbiDebug, ABI_DIR
+from abi.helpers import AbiDebug, ABI_DIR
 
 
 class AbiParser:
diff --git a/tools/lib/python/abi/abi_regex.py b/tools/lib/python/abi/abi_regex.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
 
 from pprint import pformat
 
-from abi_parser import AbiParser
-from helpers import AbiDebug
+from abi.abi_parser import AbiParser
+from abi.helpers import AbiDebug
 
 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
 
-from helpers import AbiDebug
+from abi.helpers import AbiDebug
 
 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/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/tools/lib/python/kdoc/kdoc_files.py b/tools/lib/python/kdoc/kdoc_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
 
-from kdoc_parser import KernelDoc
-from kdoc_output import OutputFormat
+from kdoc.kdoc_parser import KernelDoc
+from kdoc.kdoc_output import OutputFormat
 
 
 class GlobSourceFiles:
diff --git a/tools/lib/python/kdoc/kdoc_output.py b/tools/lib/python/kdoc/kdoc_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
 
-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
 
 
 function_pointer = KernRe(r"([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)", cache=False)
diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_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
 
-from kdoc_re import NestedMatch, KernRe
-from kdoc_item import KdocItem
+from kdoc.kdoc_re import NestedMatch, KernRe
+from kdoc.kdoc_item import KdocItem
 
 #
 # Regular expressions used to parse kernel-doc markups at KernelDoc class.
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Move Python modules to tools/lib/python
  2025-11-10 22:04 [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
  2025-11-10 22:04 ` [PATCH 1/2] docs: Move the python libraries " Jonathan Corbet
  2025-11-10 22:04 ` [PATCH 2/2] docs: bring some order to our Python module hierarchy Jonathan Corbet
@ 2025-11-18 16:27 ` Jonathan Corbet
  2025-11-18 19:16   ` Mauro Carvalho Chehab
  2 siblings, 1 reply; 5+ messages in thread
From: Jonathan Corbet @ 2025-11-18 16:27 UTC (permalink / raw)
  To: linux-doc
  Cc: linux-kernel, Mauro Carvalho Chehab, Akira Yokosawa, Jani Nikula

Jonathan Corbet <corbet@lwn.net> writes:

> scripts/lib was always a bit of an awkward place for Python libraries; give
> them a proper home under tools/lib/python.  Put the modules from
> tools/docs/lib there for good measure.
>
> The second patch ties them into a single package namespace.  It would be
> more aesthetically pleasing to add a kernel layer, so we could say:
>
>   from kernel.kdoc import kdoc_parser
>
> ...and have the kernel-specific stuff clearly marked, but that means adding
> an empty directory in the hierarchy, which isn't as pleasing.
>
> There are some other "Python library" directories hidden in the kernel
> tree; we may eventually want to encourage them to move as well.
>
> Jonathan Corbet (2):
>   docs: Move the python libraries to tools/lib/python
>   docs: bring some order to our Python module hierarchy

In the absence of complaints, I have applied these.

Thanks,

jon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Move Python modules to tools/lib/python
  2025-11-18 16:27 ` [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
@ 2025-11-18 19:16   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2025-11-18 19:16 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-doc, linux-kernel, Akira Yokosawa, Jani Nikula

Em Tue, 18 Nov 2025 09:27:05 -0700
Jonathan Corbet <corbet@lwn.net> escreveu:

> Jonathan Corbet <corbet@lwn.net> writes:
> 
> > scripts/lib was always a bit of an awkward place for Python libraries; give
> > them a proper home under tools/lib/python.  Put the modules from
> > tools/docs/lib there for good measure.
> >
> > The second patch ties them into a single package namespace.  It would be
> > more aesthetically pleasing to add a kernel layer, so we could say:
> >
> >   from kernel.kdoc import kdoc_parser
> >
> > ...and have the kernel-specific stuff clearly marked, but that means adding
> > an empty directory in the hierarchy, which isn't as pleasing.
> >
> > There are some other "Python library" directories hidden in the kernel
> > tree; we may eventually want to encourage them to move as well.
> >
> > Jonathan Corbet (2):
> >   docs: Move the python libraries to tools/lib/python
> >   docs: bring some order to our Python module hierarchy  
> 
> In the absence of complaints, I have applied these.

Sorry, I ended missing it. Looking at the changes, looks good to 
to me.

I also tested building it and everything seems fine.

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-18 19:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 22:04 [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
2025-11-10 22:04 ` [PATCH 1/2] docs: Move the python libraries " Jonathan Corbet
2025-11-10 22:04 ` [PATCH 2/2] docs: bring some order to our Python module hierarchy Jonathan Corbet
2025-11-18 16:27 ` [PATCH 0/2] Move Python modules to tools/lib/python Jonathan Corbet
2025-11-18 19:16   ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).