Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: bring some order to our Python module hierarchy

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>
Message-ID: <20251110220430.726665-3-corbet@lwn.net>

+34 -35
+2 -2
Documentation/sphinx/kernel_abi.py
··· 43 43 from sphinx.util import logging 44 44 45 45 srctree = os.path.abspath(os.environ["srctree"]) 46 - sys.path.insert(0, os.path.join(srctree, "tools/lib/python/abi")) 46 + sys.path.insert(0, os.path.join(srctree, "tools/lib/python")) 47 47 48 - from abi_parser import AbiParser 48 + from abi.abi_parser import AbiParser 49 49 50 50 __version__ = "1.0" 51 51
+2 -2
Documentation/sphinx/kernel_include.py
··· 97 97 from sphinx.util import logging 98 98 99 99 srctree = os.path.abspath(os.environ["srctree"]) 100 - sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc")) 100 + sys.path.insert(0, os.path.join(srctree, "tools/lib/python")) 101 101 102 - from parse_data_structs import ParseDataStructs 102 + from kdoc.parse_data_structs import ParseDataStructs 103 103 104 104 __version__ = "1.0" 105 105 logger = logging.getLogger(__name__)
+3 -3
Documentation/sphinx/kerneldoc.py
··· 42 42 from pprint import pformat 43 43 44 44 srctree = os.path.abspath(os.environ["srctree"]) 45 - sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc")) 45 + sys.path.insert(0, os.path.join(srctree, "tools/lib/python")) 46 46 47 - from kdoc_files import KernelFiles 48 - from kdoc_output import RestFormat 47 + from kdoc.kdoc_files import KernelFiles 48 + from kdoc.kdoc_output import RestFormat 49 49 50 50 __version__ = '1.0' 51 51 kfiles = None
+3 -3
scripts/kernel-doc.py
··· 111 111 112 112 # Import Python modules 113 113 114 - LIB_DIR = "../tools/lib/python/kdoc" 114 + LIB_DIR = "../tools/lib/python" 115 115 SRC_DIR = os.path.dirname(os.path.realpath(__file__)) 116 116 117 117 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) ··· 292 292 logger.warning("Python 3.7 or later is required for correct results") 293 293 294 294 # Import kernel-doc libraries only after checking Python version 295 - from kdoc_files import KernelFiles # pylint: disable=C0415 296 - from kdoc_output import RestFormat, ManFormat # pylint: disable=C0415 295 + from kdoc.kdoc_files import KernelFiles # pylint: disable=C0415 296 + from kdoc.kdoc_output import RestFormat, ManFormat # pylint: disable=C0415 297 297 298 298 if args.man: 299 299 out_style = ManFormat(modulename=args.modulename)
+2 -2
tools/docs/check-variable-fonts.py
··· 17 17 import os.path 18 18 19 19 src_dir = os.path.dirname(os.path.realpath(__file__)) 20 - sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) 20 + sys.path.insert(0, os.path.join(src_dir, '../lib/python')) 21 21 22 - from latex_fonts import LatexFontChecker 22 + from kdoc.latex_fonts import LatexFontChecker 23 23 24 24 checker = LatexFontChecker() 25 25
+5 -5
tools/docs/get_abi.py
··· 14 14 15 15 # Import Python modules 16 16 17 - LIB_DIR = "../lib/python/abi" 17 + LIB_DIR = "../lib/python" 18 18 SRC_DIR = os.path.dirname(os.path.realpath(__file__)) 19 19 20 20 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) 21 21 22 - from abi_parser import AbiParser # pylint: disable=C0413 23 - from abi_regex import AbiRegex # pylint: disable=C0413 24 - from helpers import ABI_DIR, DEBUG_HELP # pylint: disable=C0413 25 - from system_symbols import SystemSymbols # pylint: disable=C0413 22 + from abi.abi_parser import AbiParser # pylint: disable=C0413 23 + from abi.abi_regex import AbiRegex # pylint: disable=C0413 24 + from abi.helpers import ABI_DIR, DEBUG_HELP # pylint: disable=C0413 25 + from abi.system_symbols import SystemSymbols # pylint: disable=C0413 26 26 27 27 # Command line classes 28 28
+3 -3
tools/docs/parse-headers.py
··· 28 28 import os.path 29 29 30 30 src_dir = os.path.dirname(os.path.realpath(__file__)) 31 - sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) 32 - from parse_data_structs import ParseDataStructs 33 - from enrich_formatter import EnrichFormatter 31 + sys.path.insert(0, os.path.join(src_dir, '../lib/python')) 32 + from kdoc.parse_data_structs import ParseDataStructs 33 + from kdoc.enrich_formatter import EnrichFormatter 34 34 35 35 def main(): 36 36 """Main function"""
+2 -3
tools/docs/sphinx-build-wrapper
··· 61 61 SRC_DIR = os.path.dirname(os.path.realpath(__file__)) 62 62 63 63 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) 64 - sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR + '/kdoc')) # temporary 65 64 66 - from python_version import PythonVersion 67 - from latex_fonts import LatexFontChecker 65 + from kdoc.python_version import PythonVersion 66 + from kdoc.latex_fonts import LatexFontChecker 68 67 from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401 69 68 70 69 #
+2 -2
tools/docs/sphinx-pre-install
··· 35 35 import os.path 36 36 37 37 src_dir = os.path.dirname(os.path.realpath(__file__)) 38 - sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc')) 39 - from python_version import PythonVersion 38 + sys.path.insert(0, os.path.join(src_dir, '../lib/python')) 39 + from kdoc.python_version import PythonVersion 40 40 41 41 RECOMMENDED_VERSION = PythonVersion("3.4.3").version 42 42 MIN_PYTHON_VERSION = PythonVersion("3.7").version
tools/lib/python/__init__.py
tools/lib/python/abi/__init__.py
+1 -1
tools/lib/python/abi/abi_parser.py
··· 17 17 18 18 # Import Python modules 19 19 20 - from helpers import AbiDebug, ABI_DIR 20 + from abi.helpers import AbiDebug, ABI_DIR 21 21 22 22 23 23 class AbiParser:
+2 -2
tools/lib/python/abi/abi_regex.py
··· 12 12 13 13 from pprint import pformat 14 14 15 - from abi_parser import AbiParser 16 - from helpers import AbiDebug 15 + from abi.abi_parser import AbiParser 16 + from abi.helpers import AbiDebug 17 17 18 18 class AbiRegex(AbiParser): 19 19 """Extends AbiParser to search ABI nodes with regular expressions"""
+1 -1
tools/lib/python/abi/system_symbols.py
··· 15 15 from datetime import datetime 16 16 from random import shuffle 17 17 18 - from helpers import AbiDebug 18 + from abi.helpers import AbiDebug 19 19 20 20 class SystemSymbols: 21 21 """Stores arguments for the class and initialize class vars"""
tools/lib/python/kdoc/__init__.py
+2 -2
tools/lib/python/kdoc/kdoc_files.py
··· 13 13 import os 14 14 import re 15 15 16 - from kdoc_parser import KernelDoc 17 - from kdoc_output import OutputFormat 16 + from kdoc.kdoc_parser import KernelDoc 17 + from kdoc.kdoc_output import OutputFormat 18 18 19 19 20 20 class GlobSourceFiles:
+2 -2
tools/lib/python/kdoc/kdoc_output.py
··· 19 19 import re 20 20 from datetime import datetime 21 21 22 - from kdoc_parser import KernelDoc, type_param 23 - from kdoc_re import KernRe 22 + from kdoc.kdoc_parser import KernelDoc, type_param 23 + from kdoc.kdoc_re import KernRe 24 24 25 25 26 26 function_pointer = KernRe(r"([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)", cache=False)
+2 -2
tools/lib/python/kdoc/kdoc_parser.py
··· 16 16 import re 17 17 from pprint import pformat 18 18 19 - from kdoc_re import NestedMatch, KernRe 20 - from kdoc_item import KdocItem 19 + from kdoc.kdoc_re import NestedMatch, KernRe 20 + from kdoc.kdoc_item import KdocItem 21 21 22 22 # 23 23 # Regular expressions used to parse kernel-doc markups at KernelDoc class.