Skip to contentSkip to conversation

Raise the bar with regards to Python and Sphinx requirements

RFC In review Mauro Carvalho Chehab 4 participants 15 messages Jan 29, 2025 – Feb 5, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Raise the bar with regards to Python and Sphinx requirements

This series comes after https://lore.kernel.org/linux-doc/[email protected]/T/#t
It increases the minimal requirements for Sphinx and Python.

Sphinx release dates:

	Release 2.4.0 (released Feb 09, 2020)
	Release 2.4.4 (released Mar 05, 2020) (current minimal requirement)
	Release 3.4.0 (released Dec 20, 2020)
	Release 3.4.3 (released Jan 08, 2021)

	(https://www.sphinx-doc.org/en/master/changes/index.html)

In terms of Python, we're currently at 3.5:

	Python	Release date 
	3.5	2015-09-13    (current minimal requirement)
	3.6	2016-12-23
	3.7 	2018-06-27
	3.8 	2019-10-14
	3.9 	2020-10-05
	3.10	2021-10-04

	(according with https://en.wikipedia.org/w/index.php?title=History_of_Python)

The new minimal requirements are now:
- Sphinx 3.4.3;
- Python 3.9

The new Sphinx minimal requirement allows dropping all backward-compatible code we have at kernel-doc and at Sphinx extensions.

The new Python minimal requirement matches the current required level for all scripts but one (*). The one that doesn't match is at tools/net/sunrpc/xdrgen.

Those matches a 4-years old toolchain, which sounds a reasonable period of time, as Python/Sphinx aren't required for the Kernel build.

Mauro Carvalho Chehab (6):
scripts/get_abi.py: make it backward-compatible with Python 3.6
docs: extensions: don't use utf-8 syntax for descriptions
docs: automarkup: drop legacy support scripts/kernel-doc: drop Sphinx version check
docs: changes: update Sphinx minimal version to 3.4.3
doc: changes: update Python minimal version

 Documentation/conf.py                       |   2 +-
 Documentation/process/changes.rst           |   4 +-
 Documentation/sphinx/automarkup.py          |  32 ++---
 Documentation/sphinx/cdomain.py             |   7 +-
 Documentation/sphinx/kernel_abi.py          |   6 +-
 Documentation/sphinx/kernel_feat.py         |   4 +-
 Documentation/sphinx/kernel_include.py      |   4 +-
 Documentation/sphinx/kerneldoc.py           |   5 -
 Documentation/sphinx/kfigure.py             |  10 +-
 Documentation/sphinx/load_config.py         |   2 +-
 Documentation/sphinx/maintainers_include.py |   4 +-
 Documentation/sphinx/rstFlatTable.py        |  10 +-
 scripts/get_abi.py                          |  16 ++-
 scripts/kernel-doc                          | 129 +++-----------------
 14 files changed, 58 insertions(+), 177 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

RFC 1/6 scripts/get_abi.py: make it backward-compatible with Python 3.6

Despite being introduced on Python 3.6, the original implementation was too limited: it doesn't accept anything but the argument.

Even on python 3.10.12, support was still limited, as more complex operations cause SyntaxError:

	Exception occurred:
	  File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
	    from get_abi import AbiParser
	  File ".../linux/scripts/get_abi.py", line 525
	    msg += f"{part}\n{"-" * len(part)}\n\n"
                       ^
	SyntaxError: f-string: expecting '}'

Replace f-strings by normal string concatenation when it doesn't work on Python 3.6.

---
 scripts/get_abi.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
scripts/get_abi.py +10 -6
index 543bed397c8c..e6e94f721fff 100755
@@ -522,7 +522,7 @@ class AbiParser:
 
                 if cur_part and cur_part != part:
                     part = cur_part
-                    msg += f"{part}\n{"-" * len(part)}\n\n"
+                    msg += part + "\n"+ "-" * len(part) +"\n\n"
 
                 msg += f".. _{key}:\n\n"
 
@@ -546,7 +546,7 @@ class AbiParser:
                     msg += f"Defined on file :ref:`{base} <{ref[1]}>`\n\n"
 
             if wtype == "File":
-                msg += f"{names[0]}\n{"-" * len(names[0])}\n\n"
+                msg += names[0] +"\n" + "-" * len(names[0]) +"\n\n"
 
             desc = v.get("description")
             if not desc and wtype != "File":
@@ -570,7 +570,8 @@ class AbiParser:
 
             users = v.get("users")
             if users and users.strip(" \t\n"):
-                msg += f"Users:\n\t{users.strip("\n").replace('\n', '\n\t')}\n\n"
+                users = users.strip("\n").replace('\n', '\n\t')
+                msg += f"Users:\n\t{users}\n\n"
 
             ln = v.get("line_no", 1)
 
@@ -596,7 +597,9 @@ class AbiParser:
                 elif len(lines) == 1:
                     f.append(f"{fname}:{lines[0]}")
                 else:
-                    f.append(f"{fname} lines {", ".join(str(x) for x in lines)}")
+                    m = fname + "lines "
+                    m += ", ".join(str(x) for x in lines)
+                    f.append(m)
 
             self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
 
@@ -644,10 +647,11 @@ class AbiParser:
                     if users:
                         print(f"Users:\t\t\t{users}")
 
-                    print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".join(files)}")
+                    print("Defined on file(s):\t" + ", ".join(files))
 
                     if desc:
-                        print(f"\n{desc.strip("\n")}\n")
+                        desc = desc.strip("\n")
+                        print(f"\n{desc}\n")
 
         if not found_keys:
             print(f"Regular expression /{expr}/ not found.")
Signature · 1 line
2.48.1
Tested-by on v1 1/6
#2 lore raw

Re: [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6

Quoted 14 lines · Mauro Carvalho Chehab

Despite being introduced on Python 3.6, the original implementation was too limited: it doesn't accept anything but the argument.

Even on python 3.10.12, support was still limited, as more complex operations cause SyntaxError:

	Exception occurred:
	  File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
	    from get_abi import AbiParser
	  File ".../linux/scripts/get_abi.py", line 525
	    msg += f"{part}\n{"-" * len(part)}\n\n"
                       ^
	SyntaxError: f-string: expecting '}'
Quoted 5 lines

Replace f-strings by normal string concatenation when it doesn't work on Python 3.6.

Thanks.

maintainer
#3 lore raw

Re: [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6

In reply to Mauro Carvalho Chehab
Quoted 2 lines · Mauro Carvalho Chehab

Despite being introduced on Python 3.6, the original implementation was too limited: it doesn't accept anything but the argument.

The original implementation *of f-strings* ?

Quoted 11 lines

Even on python 3.10.12, support was still limited, as more complex operations cause SyntaxError:

	Exception occurred:
	  File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
	    from get_abi import AbiParser
	  File ".../linux/scripts/get_abi.py", line 525
	    msg += f"{part}\n{"-" * len(part)}\n\n"
                       ^
	SyntaxError: f-string: expecting '}'
Quoted 5 lines

Replace f-strings by normal string concatenation when it doesn't work on Python 3.6.

So I'm curious ... later in the series, you make 3.9 the minimal version for the kernel. Given that, is there value in adding compatibility for older versions here?

Thanks,

jon

#4 lore raw

Re: [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6

Hi,

Quoted 22 lines · Jonathan Corbet
Quoted 2 lines · Mauro Carvalho Chehab

Despite being introduced on Python 3.6, the original implementation was too limited: it doesn't accept anything but the argument.

The original implementation *of f-strings* ?

Quoted 15 lines

Even on python 3.10.12, support was still limited, as more complex operations cause SyntaxError:

	Exception occurred:
	  File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
	    from get_abi import AbiParser
	  File ".../linux/scripts/get_abi.py", line 525
	    msg += f"{part}\n{"-" * len(part)}\n\n"
                       ^
	SyntaxError: f-string: expecting '}'

Replace f-strings by normal string concatenation when it doesn't work on Python 3.6.

You might want to add

Quoted 5 lines
Quoted 1 line

So I'm curious ... later in the series, you make 3.9 the minimal version for the kernel. Given that, is there value in adding compatibility for older versions here?

I think rewording the summary to

"scripts/get_abi.py: make it backward-compatible with Python <3.11"

would resolve Jon's confusion.

I haven't looked into python3'changelog, but it might be "... backward-compatible with Python <3.12".
Mauro, which python3 release extended the f-string implementation?

Thanks, Akira

#5 lore raw

Re: [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6

Em Wed, 5 Feb 2025 11:37:52 +0900
Akira Yokosawa <[email protected]> escreveu:

Quoted 9 lines

Hi,

Quoted 6 lines · Jonathan Corbet
Quoted 2 lines · Mauro Carvalho Chehab

Despite being introduced on Python 3.6, the original implementation was too limited: it doesn't accept anything but the argument.

The original implementation *of f-strings* ?

Yes. IMO, even the original version of f-strings is better than the legacy way of using '"string" % (tuple)' or "str.format".

Besides that, there aren't many places where it uses expressions inside f-strings.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Even on python 3.10.12, support was still limited, as more complex operations cause SyntaxError:

	Exception occurred:
	  File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
	    from get_abi import AbiParser
	  File ".../linux/scripts/get_abi.py", line 525
	    msg += f"{part}\n{"-" * len(part)}\n\n"
                       ^
	SyntaxError: f-string: expecting '}'
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines

Replace f-strings by normal string concatenation when it doesn't work on Python 3.6.

You might want to add

Quoted 5 lines
Quoted 1 line

So I'm curious ... later in the series, you make 3.9 the minimal version for the kernel. Given that, is there value in adding compatibility for older versions here?

No because 3.9 is still not enough to accept a valid Python expression on f-strings. This arrived only on Python 3.12[1]:
"Expression components inside f-strings can now be any valid Python expression"

So, with this patch, doc build can be using Python 3.6. Still, it makes sense to move minimal version to 3.9 due to the current status of other Python scripts.

[1] https://docs.python.org/3/whatsnew/3.12.html#pep-701-syntactic-formalization-of-f-strings

Quoted 5 lines

I think rewording the summary to

"scripts/get_abi.py: make it backward-compatible with Python <3.11"

would resolve Jon's confusion.

Sure, but IMO it is still valuable to say somewhere that the script was tested and it is known to work since Python 3.6.

Quoted 4 lines

I haven't looked into python3'changelog, but it might be "... backward-compatible with Python <3.12".
Mauro, which python3 release extended the f-string implementation?

See above. I only did a quick check, but it sounds that 3.12 is the one that finally implemented f-strings properly in a similar way to what Perl 5 does with $'expression' inside strings.

Thanks,
Mauro

#6 lore raw

Re: [RFC 1/6] scripts/get_abi.py: make it backward-compatible with Python 3.6

Quoted 2 lines · Mauro Carvalho Chehab

Em Wed, 5 Feb 2025 11:37:52 +0900
Akira Yokosawa <[email protected]> escreveu:

[...]

Quoted 9 lines
Quoted 5 lines

I think rewording the summary to

"scripts/get_abi.py: make it backward-compatible with Python <3.11"

would resolve Jon's confusion.

Sure, but IMO it is still valuable to say somewhere that the script was tested and it is known to work since Python 3.6.

If you want "3.6" in the summary phrase, how about

"scripts/get_abi.py: make it backward-compatible with Python <3.12 >=3.6"

?

Thanks, Akira

#7 lore raw

RFC 2/6 docs: extensions: don't use utf-8 syntax for descriptions

In reply to Mauro Carvalho Chehab

None of the descriptions at the Sphinx extensions are using non-ascii characters, so no need to place them under u""" notation.

Also, according with:

	https://docs.python.org/3/deprecations/pending-removal-in-3.16.html

the 'u' format code is scheduled to be removed in Python 3.16.

So, let's just use """.

---
 Documentation/sphinx/cdomain.py             |  4 ++--
 Documentation/sphinx/kernel_abi.py          |  6 +++---
 Documentation/sphinx/kernel_feat.py         |  4 ++--
 Documentation/sphinx/kernel_include.py      |  4 ++--
 Documentation/sphinx/kfigure.py             | 10 +++++-----
 Documentation/sphinx/load_config.py         |  2 +-
 Documentation/sphinx/maintainers_include.py |  4 ++--
 Documentation/sphinx/rstFlatTable.py        | 10 +++++-----
 8 files changed, 22 insertions(+), 22 deletions(-)
Documentation/sphinx/cdomain.py +2 -2
index e6959af25402..6596fd00663f 100644
@@ -1,6 +1,6 @@
 # -*- coding: utf-8; mode: python -*-
 # pylint: disable=W0141,C0113,C0103,C0325
-u"""
+"""
     cdomain
     ~~~~~~~
 
@@ -145,7 +145,7 @@ class CObject(Base_CObject):
     }
 
     def handle_func_like_macro(self, sig, signode):
-        u"""Handles signatures of function-like macros.
+        """Handles signatures of function-like macros.
 
         If the objtype is 'function' and the signature ``sig`` is a
         function-like macro, the name of the macro is returned. Otherwise
Documentation/sphinx/kernel_abi.py +3 -3
index 379a877b75f9..9d45ad5d7b7e 100644
@@ -2,7 +2,7 @@
 # coding=utf-8
 # SPDX-License-Identifier: GPL-2.0
 #
-u"""
+"""
     kernel-abi
     ~~~~~~~~~~
 
@@ -55,7 +55,7 @@ path = os.path.join(srctree, "Documentation/ABI")
 _kernel_abi = None
 
 def get_kernel_abi():
-    u"""
+    """
     Initialize kernel_abi global var, if not initialized yet.
 
     This is needed to avoid warnings during Sphinx module initialization.
@@ -81,7 +81,7 @@ def setup(app):
 
 
 class KernelCmd(Directive):
-    u"""KernelABI (``kernel-abi``) directive"""
+    """KernelABI (``kernel-abi``) directive"""
 
     required_arguments = 1
     optional_arguments = 3
Documentation/sphinx/kernel_feat.py +2 -2
index 03ace5f01b5c..e3a51867f27b 100644
@@ -1,7 +1,7 @@
 # coding=utf-8
 # SPDX-License-Identifier: GPL-2.0
 #
-u"""
+"""
     kernel-feat
     ~~~~~~~~~~~
 
@@ -56,7 +56,7 @@ def setup(app):
 
 class KernelFeat(Directive):
 
-    u"""KernelFeat (``kernel-feat``) directive"""
+    """KernelFeat (``kernel-feat``) directive"""
 
     required_arguments = 1
     optional_arguments = 2
Documentation/sphinx/kernel_include.py +2 -2
index 638762442336..8db176045bc5 100755
@@ -2,7 +2,7 @@
 # -*- coding: utf-8; mode: python -*-
 # pylint: disable=R0903, C0330, R0914, R0912, E0401
 
-u"""
+"""
     kernel-include
     ~~~~~~~~~~~~~~
 
@@ -56,7 +56,7 @@ def setup(app):
 class KernelInclude(Include):
 # ==============================================================================
 
-    u"""KernelInclude (``kernel-include``) directive"""
+    """KernelInclude (``kernel-include``) directive"""
 
     def run(self):
         env = self.state.document.settings.env
Documentation/sphinx/kfigure.py +5 -5
index 383f9a695b08..f1a7f13c9c60 100644
@@ -1,6 +1,6 @@
 # -*- coding: utf-8; mode: python -*-
 # pylint: disable=C0103, R0903, R0912, R0915
-u"""
+"""
     scalable figure and image handling
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -165,7 +165,7 @@ def setup(app):
 
 
 def setupTools(app):
-    u"""
+    """
     Check available build tools and log some *verbose* messages.
 
     This function is called once, when the builder is initiated.
@@ -445,7 +445,7 @@ class kernel_image(nodes.image):
     pass
 
 class KernelImage(images.Image):
-    u"""KernelImage directive
+    """KernelImage directive
 
     Earns everything from ``.. image::`` directive, except *remote URI* and
     *glob* pattern. The KernelImage wraps a image node into a
@@ -481,7 +481,7 @@ class kernel_figure(nodes.figure):
     """Node for ``kernel-figure`` directive."""
 
 class KernelFigure(Figure):
-    u"""KernelImage directive
+    """KernelImage directive
 
     Earns everything from ``.. figure::`` directive, except *remote URI* and
     *glob* pattern.  The KernelFigure wraps a figure node into a kernel_figure
@@ -557,7 +557,7 @@ class kernel_render(nodes.General, nodes.Inline, nodes.Element):
     pass
 
 class KernelRender(Figure):
-    u"""KernelRender directive
+    """KernelRender directive
 
     Render content by external tool.  Has all the options known from the
     *figure*  directive, plus option ``caption``.  If ``caption`` has a
Documentation/sphinx/load_config.py +1 -1
index 8b416bfd75ac..ec50e1ee5223 100644
@@ -9,7 +9,7 @@ from sphinx.util.osutil import fs_encoding
 def loadConfig(namespace):
 # ------------------------------------------------------------------------------
 
-    u"""Load an additional configuration file into *namespace*.
+    """Load an additional configuration file into *namespace*.
 
     The name of the configuration file is taken from the environment
     ``SPHINX_CONF``. The external configuration file extends (or overwrites) the
Documentation/sphinx/maintainers_include.py +2 -2
index dcad0fff4723..d31cff867436 100755
@@ -3,7 +3,7 @@
 # -*- coding: utf-8; mode: python -*-
 # pylint: disable=R0903, C0330, R0914, R0912, E0401
 
-u"""
+"""
     maintainers-include
     ~~~~~~~~~~~~~~~~~~~
 
@@ -37,7 +37,7 @@ def setup(app):
     )
 
 class MaintainersInclude(Include):
-    u"""MaintainersInclude (``maintainers-include``) directive"""
+    """MaintainersInclude (``maintainers-include``) directive"""
     required_arguments = 0
 
     def parse_maintainers(self, path):
Documentation/sphinx/rstFlatTable.py +5 -5
index 16bea0632555..180fbb50c337 100755
@@ -2,7 +2,7 @@
 # -*- coding: utf-8; mode: python -*-
 # pylint: disable=C0330, R0903, R0912
 
-u"""
+"""
     flat-table
     ~~~~~~~~~~
 
@@ -99,7 +99,7 @@ class colSpan(nodes.General, nodes.Element): pass # pylint: disable=C0103,C0321
 class FlatTable(Table):
 # ==============================================================================
 
-    u"""FlatTable (``flat-table``) directive"""
+    """FlatTable (``flat-table``) directive"""
 
     option_spec = {
         'name': directives.unchanged
@@ -135,7 +135,7 @@ class FlatTable(Table):
 class ListTableBuilder(object):
 # ==============================================================================
 
-    u"""Builds a table from a double-stage list"""
+    """Builds a table from a double-stage list"""
 
     def __init__(self, directive):
         self.directive = directive
@@ -212,7 +212,7 @@ class ListTableBuilder(object):
         raise SystemMessagePropagation(error)
 
     def parseFlatTableNode(self, node):
-        u"""parses the node from a :py:class:`FlatTable` directive's body"""
+        """parses the node from a :py:class:`FlatTable` directive's body"""
 
         if len(node) != 1 or not isinstance(node[0], nodes.bullet_list):
             self.raiseError(
@@ -225,7 +225,7 @@ class ListTableBuilder(object):
         self.roundOffTableDefinition()
 
     def roundOffTableDefinition(self):
-        u"""Round off the table definition.
+        """Round off the table definition.
 
         This method rounds off the table definition in :py:member:`rows`.
 
Signature · 1 line
2.48.1
maintainer
#8 lore raw

Re: [RFC 2/6] docs: extensions: don't use utf-8 syntax for descriptions

Quoted 4 lines · Mauro Carvalho Chehab

None of the descriptions at the Sphinx extensions are using non-ascii characters, so no need to place them under u""" notation.

Quoted 8 lines

Also, according with:

	https://docs.python.org/3/deprecations/pending-removal-in-3.16.html

the 'u' format code is scheduled to be removed in Python 3.16.

So, let's just use """.

...plus it's all utf8 by default anyway. I'm kind of surprised we have these, I guess they must be a Python 2 holdover.

jon

#9 lore raw

RFC 3/6 docs: automarkup: drop legacy support

In reply to Mauro Carvalho Chehab

Python 2 is already EOL for quite some time. Drop support for it.

Also, the minimal Sphinx version is now 3.4.3. So, we can drop support for Sphinx < 3.

---
 Documentation/sphinx/automarkup.py | 32 +++++++-----------------------
 1 file changed, 7 insertions(+), 25 deletions(-)
Documentation/sphinx/automarkup.py +7 -25
index 03bb7020f5cb..ecf54d22e9dc 100644
@@ -13,14 +13,6 @@ from itertools import chain
 
 from kernel_abi import get_kernel_abi
 
-#
-# Python 2 lacks re.ASCII...
-#
-try:
-    ascii_p3 = re.ASCII
-except AttributeError:
-    ascii_p3 = 0
-
 #
 # Regex nastiness.  Of course.
 # Try to identify "function()" that's not already marked up some
@@ -28,22 +20,22 @@ except AttributeError:
 # :c:func: block (i.e. ":c:func:`mmap()`s" flakes out), so the last
 # bit tries to restrict matches to things that won't create trouble.
 #
-RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=ascii_p3)
+RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=re.ASCII)
 
 #
 # Sphinx 2 uses the same :c:type role for struct, union, enum and typedef
 #
 RE_generic_type = re.compile(r'\b(struct|union|enum|typedef)\s+([a-zA-Z_]\w+)',
-                             flags=ascii_p3)
+                             flags=re.ASCII)
 
 #
 # Sphinx 3 uses a different C role for each one of struct, union, enum and
 # typedef
 #
-RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
-RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
-RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
-RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
+RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
 
 #
 # Detects a reference to a documentation page of the form Documentation/... with
@@ -87,13 +79,8 @@ def markup_refs(docname, app, node):
     #
     # Associate each regex with the function that will markup its matches
     #
-    markup_func_sphinx2 = {RE_doc: markup_doc_ref,
-                           RE_abi_file: markup_abi_file_ref,
-                           RE_abi_symbol: markup_abi_ref,
-                           RE_function: markup_c_ref,
-                           RE_generic_type: markup_c_ref}
 
-    markup_func_sphinx3 = {RE_doc: markup_doc_ref,
+    markup_func = {RE_doc: markup_doc_ref,
                            RE_abi_file: markup_abi_file_ref,
                            RE_abi_symbol: markup_abi_ref,
                            RE_function: markup_func_ref_sphinx3,
@@ -103,11 +90,6 @@ def markup_refs(docname, app, node):
                            RE_typedef: markup_c_ref,
                            RE_git: markup_git}
 
-    if sphinx.version_info[0] >= 3:
-        markup_func = markup_func_sphinx3
-    else:
-        markup_func = markup_func_sphinx2
-
     match_iterators = [regex.finditer(t) for regex in markup_func]
     #
     # Sort all references by the starting position in text
Signature · 1 line
2.48.1
#10 lore raw

RFC 4/6 scripts/kernel-doc: drop Sphinx version check

In reply to Mauro Carvalho Chehab

As the current minimal supported Sphinx version is 3.4.3, drop support for older versions.

---
 Documentation/sphinx/cdomain.py   |   3 -
 Documentation/sphinx/kerneldoc.py |   5 --
 scripts/kernel-doc                | 129 ++++--------------------------
 3 files changed, 16 insertions(+), 121 deletions(-)
Documentation/sphinx/cdomain.py +0 -3
index 6596fd00663f..e8ea80d4324c 100644
@@ -45,9 +45,6 @@ import re
 
 __version__  = '1.1'
 
-# Get Sphinx version
-major, minor, patch = sphinx.version_info[:3]
-
 # Namespace to be prepended to the full name
 namespace = None
 
Documentation/sphinx/kerneldoc.py +0 -5
index be5b8fbf373f..39ddae6ae7dd 100644
@@ -62,11 +62,6 @@ class KernelDocDirective(Directive):
         env = self.state.document.settings.env
         cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
 
-        # Pass the version string to kernel-doc, as it needs to use a different
-        # dialect, depending what the C domain supports for each specific
-        # Sphinx versions
-        cmd += ['-sphinx-version', sphinx.__version__]
-
         filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
         export_file_patterns = []
 
scripts/kernel-doc +16 -113

206 lines not on this page · raw message

Signature · 1 line
2.48.1
#11 lore raw

RFC 5/6 docs: changes: update Sphinx minimal version to 3.4.3

In reply to Mauro Carvalho Chehab

Doing that allows us to get rid of all backward-compatible code.

---
 Documentation/conf.py             | 2 +-
 Documentation/process/changes.rst | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/conf.py +1 -1
index 0c2205d536b3..3dad1f90b098 100644
@@ -47,7 +47,7 @@ from load_config import loadConfig
 # -- General configuration ------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
-needs_sphinx = '2.4.4'
+needs_sphinx = '3.4.3'
 
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
Documentation/process/changes.rst +1 -1
index 82b5e378eebf..012d2b715c2a 100644
@@ -58,7 +58,7 @@ mcelog                 0.6              mcelog --version
 iptables               1.4.2            iptables -V
 openssl & libcrypto    1.0.0            openssl version
 bc                     1.06.95          bc --version
-Sphinx\ [#f1]_         2.4.4            sphinx-build --version
+Sphinx\ [#f1]_         3.4.3            sphinx-build --version
 cpio                   any              cpio --version
 GNU tar                1.28             tar --version
 gtags (optional)       6.6.5            gtags --version
Signature · 1 line
2.48.1
#12 lore raw

RFC 6/6 doc: changes: update Python minimal version

In reply to Mauro Carvalho Chehab

The current minimal version doesn't match what we have currently at the Kernel:

	$ vermin -v  $(git ls-files *.py)
	...
	Minimum required versions: 3.10
	Incompatible versions:     2

Those are the Python scripts requiring versions higher than current minimal (3.5):

        !2, 3.10     tools/net/sunrpc/xdrgen/generators/__init__.py
        !2, 3.10     tools/net/sunrpc/xdrgen/generators/program.py
        !2, 3.10     tools/net/sunrpc/xdrgen/subcmds/source.py
        !2, 3.10     tools/net/sunrpc/xdrgen/xdr_ast.py
        !2, 3.10     tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py
        !2, 3.9      tools/testing/selftests/net/rds/test.py
        !2, 3.9      tools/net/ynl/ethtool.py
        !2, 3.9      tools/net/ynl/cli.py
        !2, 3.9      scripts/checktransupdate.py
        !2, 3.8      tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py
        !2, 3.8      tools/testing/selftests/hid/tests/base.py
        !2, 3.7      tools/testing/selftests/turbostat/smi_aperf_mperf.py
        !2, 3.7      tools/testing/selftests/turbostat/defcolumns.py
        !2, 3.7      tools/testing/selftests/turbostat/added_perf_counters.py
        !2, 3.7      tools/testing/selftests/hid/tests/conftest.py
        !2, 3.7      tools/testing/kunit/qemu_config.py
        !2, 3.7      tools/testing/kunit/kunit_tool_test.py
        !2, 3.7      tools/testing/kunit/kunit.py
        !2, 3.7      tools/testing/kunit/kunit_parser.py
        !2, 3.7      tools/testing/kunit/kunit_kernel.py
        !2, 3.7      tools/testing/kunit/kunit_json.py
        !2, 3.7      tools/testing/kunit/kunit_config.py
        !2, 3.7      tools/perf/scripts/python/gecko.py
        !2, 3.7      scripts/rust_is_available_test.py
        !2, 3.7      scripts/bpf_doc.py
        !2, 3.6      tools/writeback/wb_monitor.py
        !2, 3.6      tools/workqueue/wq_monitor.py
        !2, 3.6      tools/workqueue/wq_dump.py
        !2, 3.6      tools/usb/p9_fwd.py
        !2, 3.6      tools/tracing/rtla/sample/timerlat_load.py
        !2, 3.6      tools/testing/selftests/net/openvswitch/ovs-dpctl.py
        !2, 3.6      tools/testing/selftests/net/nl_netdev.py
        !2, 3.6      tools/testing/selftests/net/lib/py/ynl.py
        !2, 3.6      tools/testing/selftests/net/lib/py/utils.py
        !2, 3.6      tools/testing/selftests/net/lib/py/nsim.py
        !2, 3.6      tools/testing/selftests/net/lib/py/netns.py
        !2, 3.6      tools/testing/selftests/net/lib/py/ksft.py
        !2, 3.6      tools/testing/selftests/kselftest/ksft.py
        !2, 3.6      tools/testing/selftests/hid/tests/test_tablet.py
        !2, 3.6      tools/testing/selftests/hid/tests/test_sony.py
        !2, 3.6      tools/testing/selftests/hid/tests/test_multitouch.py
        !2, 3.6      tools/testing/selftests/hid/tests/test_mouse.py
        !2, 3.6      tools/testing/selftests/hid/tests/base_gamepad.py
        !2, 3.6      tools/testing/selftests/hid/tests/base_device.py
        !2, 3.6      tools/testing/selftests/drivers/net/stats.py
        !2, 3.6      tools/testing/selftests/drivers/net/shaper.py
        !2, 3.6      tools/testing/selftests/drivers/net/queues.py
        !2, 3.6      tools/testing/selftests/drivers/net/ping.py
        !2, 3.6      tools/testing/selftests/drivers/net/lib/py/remote_ssh.py
        !2, 3.6      tools/testing/selftests/drivers/net/lib/py/load.py
        !2, 3.6      tools/testing/selftests/drivers/net/lib/py/__init__.py
        !2, 3.6      tools/testing/selftests/drivers/net/lib/py/env.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/rss_ctx.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/nic_performance.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/nic_link_layer.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/lib/py/linkconfig.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/lib/py/__init__.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/devmem.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/devlink_port_split.py
        !2, 3.6      tools/testing/selftests/drivers/net/hw/csum.py
        !2, 3.6      tools/testing/selftests/devices/probe/test_discoverable_devices.py
        !2, 3.6      tools/testing/selftests/bpf/test_bpftool_synctypes.py
        !2, 3.6      tools/testing/selftests/bpf/generate_udp_fragments.py
        !2, 3.6      tools/testing/kunit/run_checks.py
        !2, 3.6      tools/testing/kunit/kunit_printer.py
        !2, 3.6      tools/sched_ext/scx_show_state.py
        !2, 3.6      tools/perf/tests/shell/lib/perf_metric_validation.py
        !2, 3.6      tools/perf/tests/shell/lib/perf_json_output_lint.py
        !2, 3.6      tools/perf/scripts/python/parallel-perf.py
        !2, 3.6      tools/perf/scripts/python/flamegraph.py
        !2, 3.6      tools/perf/scripts/python/arm-cs-trace-disasm.py
        !2, 3.6      tools/perf/pmu-events/models.py
        !2, 3.6      tools/perf/pmu-events/metric_test.py
        !2, 3.6      tools/perf/pmu-events/metric.py
        !2, 3.6      tools/perf/pmu-events/jevents.py
        !2, 3.6      tools/net/ynl/ynl-gen-rst.py
        !2, 3.6      tools/net/ynl/ynl-gen-c.py
        !2, 3.6      tools/net/ynl/lib/ynl.py
        !2, 3.6      tools/net/ynl/lib/nlspec.py
        !2, 3.6      tools/crypto/tcrypt/tcrypt_speed_compare.py
        !2, 3.6      tools/cgroup/iocost_monitor.py
        !2, 3.6      tools/cgroup/iocost_coef_gen.py
        !2, 3.6      scripts/make_fit.py
        !2, 3.6      scripts/macro_checker.py
        !2, 3.6      scripts/get_abi.py
        !2, 3.6      scripts/generate_rust_analyzer.py
        !2, 3.6      scripts/gdb/linux/timerlist.py
        !2, 3.6      scripts/gdb/linux/pgtable.py
        !2, 3.6      scripts/clang-tools/run-clang-tools.py
        !2, 3.6      Documentation/sphinx/automarkup.py

Even if we exclude tools/net/sunrpc/xdrgen/, the minimal version is Python 3.9.

Update process/changes to reflect the current minimal version required to run Python scripts outside tools.

---
 Documentation/process/changes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/process/changes.rst +1 -1
index 012d2b715c2a..e12aa044e09a 100644
@@ -63,7 +63,7 @@ cpio                   any              cpio --version
 GNU tar                1.28             tar --version
 gtags (optional)       6.6.5            gtags --version
 mkimage (optional)     2017.01          mkimage --version
-Python (optional)      3.5.x            python3 --version
+Python (optional)      3.9.x            python3 --version
 GNU AWK (optional)     5.1.0            gawk --version
 ====================== ===============  ========================================
 
Signature · 1 line
2.48.1
#13 lore raw
In reply to Mauro Carvalho Chehab
Quoted 11 lines · Mauro Carvalho Chehab

This series comes after https://lore.kernel.org/linux-doc/[email protected]/T/#t
It increases the minimal requirements for Sphinx and Python.

Sphinx release dates:

	Release 2.4.0 (released Feb 09, 2020)
	Release 2.4.4 (released Mar 05, 2020) (current minimal requirement)
	Release 3.4.0 (released Dec 20, 2020)
	Release 3.4.3 (released Jan 08, 2021)

	(https://www.sphinx-doc.org/en/master/changes/index.html)

It's worth mentioning here that my fix for the C performance regression landed in Sphinx 7.4.0. All versions from 3.0.0 to 7.3.x are much slower for building the kernel docs. See #12162 here:

https://www.sphinx-doc.org/en/master/changes/7.4.html#id7

maintainer
#14 lore raw
Quoted 12 lines · Donald Hunter
Quoted 10 lines · Mauro Carvalho Chehab

This series comes after https://lore.kernel.org/linux-doc/[email protected]/T/#t
It increases the minimal requirements for Sphinx and Python.

Sphinx release dates:

	Release 2.4.0 (released Feb 09, 2020)
	Release 2.4.4 (released Mar 05, 2020) (current minimal requirement)
	Release 3.4.0 (released Dec 20, 2020)
	Release 3.4.3 (released Jan 08, 2021)
Quoted 7 lines
Quoted 1 line

(https://www.sphinx-doc.org/en/master/changes/index.html)

It's worth mentioning here that my fix for the C performance regression landed in Sphinx 7.4.0. All versions from 3.0.0 to 7.3.x are much slower for building the kernel docs. See #12162 here:

https://www.sphinx-doc.org/en/master/changes/7.4.html#id7

Indeed, we have noticed the speedup - much appreciated, thank you!

jon