From: Andrei Pavel Date: Tue, 1 Apr 2025 12:22:16 +0000 (+0300) Subject: [#3812] hammer.py: Add pyinstall_sphinx X-Git-Tag: Kea-2.7.8~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6d5a6133a1d880f381f38317a3a0ee0106413695;p=thirdparty%2Fkea.git [#3812] hammer.py: Add pyinstall_sphinx --- diff --git a/hammer.py b/hammer.py index a04c067f19..dd8f6b9f9b 100755 --- a/hammer.py +++ b/hammer.py @@ -471,6 +471,9 @@ def pyinstall_meson(python_v: str = 'python3'): :type python_v: str """ + exit_code = execute('meson --version', quiet=True, raise_error=False) + if exit_code == 0: + return execute('rm -fr .meson .meson-src .venv') execute('git clone https://github.com/mesonbuild/meson .meson-src') _, output = execute('git tag -l', cwd='.meson-src', capture=True, quiet=True) @@ -487,6 +490,26 @@ def pyinstall_meson(python_v: str = 'python3'): execute('rm -fr .meson .meson-src .venv') +def pyinstall_sphinx(python_v: str = 'python3'): + """ Install sphinx with pyinstaller. + + :param python_v: python executable + :type python_v: str + """ + + exit_code = execute('sphinx-build --version', quiet=True, raise_error=False) + if exit_code == 0: + return + execute(f'{python_v} -m venv .venv') + execute('.venv/bin/pip install --upgrade pip') + execute('.venv/bin/pip install pyinstaller') + execute('.venv/bin/pip install sphinx') + execute('.venv/bin/pip install sphinx_rtd_theme') + execute('.venv/bin/pyinstaller --clean --collect-all sphinx_rtd_theme --collect-all sphinxcontrib --clean ' + '--onefile .venv/bin/sphinx-build') + execute('sudo cp dist/sphinx-build /usr/local/bin') + + def _prepare_installed_packages_cache_for_debs(): pkg_cache = {} @@ -1840,9 +1863,9 @@ def install_packages_local(system, revision, features, check_times, ignore_error packages.append('boost169-devel') if 'docs' in features: - packages.extend(['python3-sphinx', 'python3-sphinx_rtd_theme', 'texlive', 'texlive-capt-of', - 'texlive-fncychap', 'texlive-framed', 'texlive-needspace', 'texlive-tabulary', - 'texlive-titlesec', 'texlive-upquote', 'texlive-wrapfig']) + packages.extend(['texlive', 'texlive-capt-of', 'texlive-fncychap', 'texlive-framed', 'texlive-needspace', + 'texlive-tabulary', 'texlive-titlesec', 'texlive-upquote', 'texlive-wrapfig']) + deferred_functions.append(lambda: pyinstall_sphinx(python_v)) if 'native-pkg' in features: packages.extend(['python3-devel', 'rpm-build']) @@ -1881,9 +1904,9 @@ def install_packages_local(system, revision, features, check_times, ignore_error deferred_functions.append(pyinstall_meson) if 'docs' in features: - packages.extend(['python3-sphinx', 'python3-sphinx_rtd_theme', 'texlive', 'texlive-capt-of', - 'texlive-fncychap', 'texlive-framed', 'texlive-needspace', 'texlive-tabulary', - 'texlive-titlesec', 'texlive-upquote', 'texlive-wrapfig']) + packages.extend(['texlive', 'texlive-capt-of', 'texlive-fncychap', 'texlive-framed', 'texlive-needspace', + 'texlive-tabulary', 'texlive-titlesec', 'texlive-upquote', 'texlive-wrapfig']) + deferred_functions.append(pyinstall_sphinx) if 'native-pkg' in features: packages.extend(['python3-devel', 'rpm-build']) @@ -1962,8 +1985,8 @@ def install_packages_local(system, revision, features, check_times, ignore_error deferred_functions.append(pyinstall_meson) if 'docs' in features: - packages.extend(['python3-sphinx', 'python3-sphinx-rtd-theme', 'doxygen', 'graphviz', - 'tex-gyre', 'texlive', 'texlive-latex-extra']) + packages.extend(['doxygen', 'graphviz', 'tex-gyre', 'texlive', 'texlive-latex-extra']) + deferred_functions.append(pyinstall_sphinx) if 'unittest' in features: packages.append('googletest')