# Sphinx versions to be installed and their incremental requirements
SPHINX_REQUIREMENTS = { # Oldest versions we support for each package required by Sphinx 3.4.3
(3, 4, 3): { "docutils": "0.16", "alabaster": "0.7.12", "babel": "2.8.0", "certifi": "2020.6.20", "docutils": "0.16", "idna": "2.10", "imagesize": "1.2.0", "Jinja2": "2.11.2", "MarkupSafe": "1.1.1", "packaging": "20.4", "Pygments": "2.6.1", "PyYAML": "5.1", "requests": "2.24.0", "snowballstemmer": "2.0.0", "sphinxcontrib-applehelp": "1.0.2", "sphinxcontrib-devhelp": "1.0.2", "sphinxcontrib-htmlhelp": "1.0.3", "sphinxcontrib-jsmath": "1.0.1", "sphinxcontrib-qthelp": "1.0.3", "sphinxcontrib-serializinghtml": "1.1.4", "urllib3": "1.25.9",
},
# Update package dependencies to a more modern base. The goal here # is to avoid to many incremental changes for the next entries
(3, 5, 0): { "alabaster": "0.7.13", "babel": "2.17.0", "certifi": "2025.6.15", "idna": "3.10", "imagesize": "1.4.1", "packaging": "25.0", "Pygments": "2.8.1", "requests": "2.32.4", "snowballstemmer": "3.0.1", "sphinxcontrib-applehelp": "1.0.4", "sphinxcontrib-htmlhelp": "2.0.1", "sphinxcontrib-serializinghtml": "1.1.5", "urllib3": "2.0.0",
},
def log(self, out, verbose, is_info=True):
out = out.removesuffix('\n')
if verbose: if is_info:
print(out) else:
print(out, file=sys.stderr)
if self.fp:
self.fp.write(out + "\n")
async def _read(self, stream, verbose, is_info): """Ancillary routine to capture while displaying"""
while stream isnotNone:
line = await stream.readline() if line:
out = line.decode("utf-8", errors="backslashreplace")
self.log(out, verbose, is_info) if is_info:
self.stdout += out else:
self.stderr += out else: break
# Handle input and output in realtime
await asyncio.gather(
self._read(proc.stdout, verbose, True),
self._read(proc.stderr, verbose, False),
)
await proc.wait()
if check and proc.returncode > 0: raise subprocess.CalledProcessError(returncode=proc.returncode,
cmd=" ".join(cmd),
output=self.stdout,
stderr=self.stderr)
if capture_output: if proc.returncode > 0:
self.log(f"Error {proc.returncode}", verbose=True, is_info=False) return""
return self.output
ret = subprocess.CompletedProcess(args=cmd,
returncode=proc.returncode,
stdout=self.stdout,
stderr=self.stderr)
return ret
class SphinxVenv: """
Installs Sphinx on one virtual env per Sphinx version with a minimal
set of dependencies, adjusting them to each specific version. """
async def _handle_version(self, args, fp,
cur_ver, cur_requirements, python_bin): """Handle a single Sphinx version"""
cmd = AsyncCommands(fp)
ver = ".".join(map(str, cur_ver))
ifnot self.first_run and args.wait_input and args.build:
ret = input("Press Enter to continue or 'a' to abort: ").strip().lower() if ret == "a":
print("Aborted.")
sys.exit() else:
self.first_run = False
DESCRIPTION = f"""
This tool allows creating Python virtual environments for different
Sphinx versions that are supported by the Linux Kernel build system.
Besides creating the virtual environment, it can also test building
the documentation using "make htmldocs" (and/or other doc targets).
If called without "--versions" argument, it covers the versions shipped
on major distros, plus the lowest supported version:
{DEFAULT_VERS}
A typical usage is to run:
{SCRIPT} -m -l sphinx_builds.log
This will create one virtual env for the default version set and run "make htmldocs"for each version, creating a log file with the
excecuted commands on it.
NOTE: The build time can be very long, specially on old versions. Also, there is a known bug with Sphinx version 6.0.x: each subprocess uses a lot of
memory. That, together with"-jauto" may cause OOM killer to cause
failures at the doc generation. To minimize the risk, you may use the "-a" command line parameter to constrain the built directories and/or
reduce the number of threads from"-jauto" to, for instance, "-j4":
{SCRIPT} -m -V 6.0.1 -a "SPHINXDIRS=process""SPHINXOPTS='-j4'"
other_group.add_argument('-r', '--req-file', action='store_true',
help='write a requirements.txt file')
other_group.add_argument('-l', '--log',
help='Log command output on a file')
other_group.add_argument('-v', '--verbose', action='store_true',
help='Verbose all commands')
other_group.add_argument('-i', '--wait-input', action='store_true',
help='Wait for an enter before going to the next version')
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.