diff options
| author | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2025-08-12 17:52:44 +0200 | 
|---|---|---|
| committer | Jonathan Corbet <corbet@lwn.net> | 2025-08-13 10:19:17 -0600 | 
| commit | 1e9ba3b6d4cef8b1b87d6226ab7026c9745cc1d7 (patch) | |
| tree | 4f773a0d89540915951eab965e6b4f940f71f226 /scripts/sphinx-pre-install.py | |
| parent | 2cab00fb178a31bca45adc1ff5f0994679d116a4 (diff) | |
scripts: sphinx-pre-install: move ancillary checkers to a separate class
The code there are just a bunch of static functions that are used by
the main class. group them altogether to better organize the code.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/e2671eb14fae7a8510f5305ac44ad8063e237a5f.1754992972.git.mchehab+huawei@kernel.org
Diffstat (limited to 'scripts/sphinx-pre-install.py')
| -rwxr-xr-x | scripts/sphinx-pre-install.py | 160 | 
1 files changed, 81 insertions, 79 deletions
diff --git a/scripts/sphinx-pre-install.py b/scripts/sphinx-pre-install.py index 47dce1fcddfb..b00e50028f4d 100755 --- a/scripts/sphinx-pre-install.py +++ b/scripts/sphinx-pre-install.py @@ -150,85 +150,11 @@ class DepManager:          if output_msg:              print(f"\n{output_msg}\n") -class SphinxDependencyChecker: -    # List of required texlive packages on Fedora and OpenSuse -    texlive = { -        "amsfonts.sty":       "texlive-amsfonts", -        "amsmath.sty":        "texlive-amsmath", -        "amssymb.sty":        "texlive-amsfonts", -        "amsthm.sty":         "texlive-amscls", -        "anyfontsize.sty":    "texlive-anyfontsize", -        "atbegshi.sty":       "texlive-oberdiek", -        "bm.sty":             "texlive-tools", -        "capt-of.sty":        "texlive-capt-of", -        "cmap.sty":           "texlive-cmap", -        "ctexhook.sty":       "texlive-ctex", -        "ecrm1000.tfm":       "texlive-ec", -        "eqparbox.sty":       "texlive-eqparbox", -        "eu1enc.def":         "texlive-euenc", -        "fancybox.sty":       "texlive-fancybox", -        "fancyvrb.sty":       "texlive-fancyvrb", -        "float.sty":          "texlive-float", -        "fncychap.sty":       "texlive-fncychap", -        "footnote.sty":       "texlive-mdwtools", -        "framed.sty":         "texlive-framed", -        "luatex85.sty":       "texlive-luatex85", -        "multirow.sty":       "texlive-multirow", -        "needspace.sty":      "texlive-needspace", -        "palatino.sty":       "texlive-psnfss", -        "parskip.sty":        "texlive-parskip", -        "polyglossia.sty":    "texlive-polyglossia", -        "tabulary.sty":       "texlive-tabulary", -        "threeparttable.sty": "texlive-threeparttable", -        "titlesec.sty":       "texlive-titlesec", -        "ucs.sty":            "texlive-ucs", -        "upquote.sty":        "texlive-upquote", -        "wrapfig.sty":        "texlive-wrapfig", -    } - -    def __init__(self, args): -        self.pdf = args.pdf -        self.virtualenv = args.virtualenv -        self.version_check = args.version_check - -        self.deps = DepManager(self.pdf) - -        self.need_symlink = 0 -        self.need_sphinx = 0 -        self.need_pip = 0 -        self.rec_sphinx_upgrade = 0 -        self.verbose_warn_install = 1 - -        self.system_release = "" -        self.install = "" -        self.virtenv_dir = "" -        self.python_cmd = "" -        self.activate_cmd = "" - -        # Some distros may not have a Sphinx shipped package compatible with -        # our minimal requirements -        self.package_supported = True - -        # Recommend a new python version -        self.recommend_python = None - -        # Certain hints are meant to be shown only once -        self.first_hint = True - -        self.min_version = (0, 0, 0) -        self.cur_version = (0, 0, 0) -        self.latest_avail_ver = (0, 0, 0) -        self.venv_ver = (0, 0, 0) - -        prefix = os.environ.get("srctree", ".") + "/" - -        self.conf = prefix + "Documentation/conf.py" -        self.requirement_file = prefix + "Documentation/sphinx/requirements.txt" -        self.virtenv_prefix = ["sphinx_", "Sphinx_" ] - -    # -    # Ancillary methods that don't depend on self -    # +class AncillaryCheckers: +    """ +    Ancillary methods that checks for missing dependencies for different +    types of types, like binaries, python modules, rpm deps, etc. +    """      @staticmethod      def which(prog): @@ -335,6 +261,82 @@ class SphinxDependencyChecker:          return subprocess.run(*args, **kwargs) +class SphinxDependencyChecker(AncillaryCheckers): +    # List of required texlive packages on Fedora and OpenSuse +    texlive = { +        "amsfonts.sty":       "texlive-amsfonts", +        "amsmath.sty":        "texlive-amsmath", +        "amssymb.sty":        "texlive-amsfonts", +        "amsthm.sty":         "texlive-amscls", +        "anyfontsize.sty":    "texlive-anyfontsize", +        "atbegshi.sty":       "texlive-oberdiek", +        "bm.sty":             "texlive-tools", +        "capt-of.sty":        "texlive-capt-of", +        "cmap.sty":           "texlive-cmap", +        "ctexhook.sty":       "texlive-ctex", +        "ecrm1000.tfm":       "texlive-ec", +        "eqparbox.sty":       "texlive-eqparbox", +        "eu1enc.def":         "texlive-euenc", +        "fancybox.sty":       "texlive-fancybox", +        "fancyvrb.sty":       "texlive-fancyvrb", +        "float.sty":          "texlive-float", +        "fncychap.sty":       "texlive-fncychap", +        "footnote.sty":       "texlive-mdwtools", +        "framed.sty":         "texlive-framed", +        "luatex85.sty":       "texlive-luatex85", +        "multirow.sty":       "texlive-multirow", +        "needspace.sty":      "texlive-needspace", +        "palatino.sty":       "texlive-psnfss", +        "parskip.sty":        "texlive-parskip", +        "polyglossia.sty":    "texlive-polyglossia", +        "tabulary.sty":       "texlive-tabulary", +        "threeparttable.sty": "texlive-threeparttable", +        "titlesec.sty":       "texlive-titlesec", +        "ucs.sty":            "texlive-ucs", +        "upquote.sty":        "texlive-upquote", +        "wrapfig.sty":        "texlive-wrapfig", +    } + +    def __init__(self, args): +        self.pdf = args.pdf +        self.virtualenv = args.virtualenv +        self.version_check = args.version_check + +        self.deps = DepManager(self.pdf) + +        self.need_symlink = 0 +        self.need_sphinx = 0 +        self.need_pip = 0 +        self.rec_sphinx_upgrade = 0 +        self.verbose_warn_install = 1 + +        self.system_release = "" +        self.install = "" +        self.virtenv_dir = "" +        self.python_cmd = "" +        self.activate_cmd = "" + +        # Some distros may not have a Sphinx shipped package compatible with +        # our minimal requirements +        self.package_supported = True + +        # Recommend a new python version +        self.recommend_python = None + +        # Certain hints are meant to be shown only once +        self.first_hint = True + +        self.min_version = (0, 0, 0) +        self.cur_version = (0, 0, 0) +        self.latest_avail_ver = (0, 0, 0) +        self.venv_ver = (0, 0, 0) + +        prefix = os.environ.get("srctree", ".") + "/" + +        self.conf = prefix + "Documentation/conf.py" +        self.requirement_file = prefix + "Documentation/sphinx/requirements.txt" +        self.virtenv_prefix = ["sphinx_", "Sphinx_" ] +      #      # Methods to check if a feature exists      #  | 
