SPB Git

Repository Public License Research preview

check_toolchain.py 2.3 KB 47 lines python

1#!/usr/bin/env python32"""Verify the local toolchain. Reports what is missing; installs nothing."""3from __future__ import annotations45import shutil6import subprocess7import sys89REQUIRED = {"lualatex": "TeX Live (LuaLaTeX)", "latexmk": "TeX Live (latexmk)", "biber": "biber (bibliography)",10            "pdftoppm": "poppler", "pdfinfo": "poppler", "pdffonts": "poppler", "pdftotext": "poppler", "git": "git"}11OPTIONAL = {"pdftocairo": "poppler (SVG previews of figures)", "make": "make (on Windows, call the tools/*.py scripts directly)"}12TEX_FILES = ["beamer.cls", "tikz.sty", "pgfplots.sty", "tcolorbox.sty", "biblatex.sty", "fontspec.sty",13             "unicode-math.sty", "csquotes.sty", "standalone.cls", "colortbl.sty", "booktabs.sty",14             "FiraSans-Regular.otf", "FiraMono-Regular.otf", "FiraMath-Regular.otf"]151617def main() -> int:18    missing = 019    for exe, what in REQUIRED.items():20        found = shutil.which(exe)21        print(f"{'ok     ' if found else 'MISSING'} {exe:<11} {what}")22        missing += not found23    for exe, what in OPTIONAL.items():24        print(f"{'ok     ' if shutil.which(exe) else 'optional'} {exe:<11} {what}")25    if shutil.which("kpsewhich"):26        for f in TEX_FILES:27            found = subprocess.run(["kpsewhich", f], capture_output=True, text=True).stdout.strip()28            fallback = " (decks fall back to Latin Modern)" if f.startswith("Fira") and not found else ""29            print(f"{'ok     ' if found else 'MISSING'} {f}{fallback}")30            missing += (not found) and not f.startswith("Fira")31    print(f"ok      python      {sys.version.split()[0]}" if sys.version_info >= (3, 10) else "MISSING python >= 3.10")32    missing += sys.version_info < (3, 10)33    for mod, need in (("yaml", "required: PyYAML"), ("pytest", "required for tests"), ("PIL", "optional: Pillow, contact sheets")):34        try:35            __import__(mod)36            print(f"ok      python module {mod}")37        except ImportError:38            print(f"{'optional' if 'optional' in need else 'MISSING'} python module {mod} ({need})")39            missing += "optional" not in need40    print("\nToolchain complete." if not missing else f"\n{missing} required component(s) missing. "41          "Nothing was installed; see docs/architecture.md (Toolchain).")42    return 1 if missing else 0434445if __name__ == "__main__":46    sys.exit(main())47
Files main
Menu

Theme