Show a clear message when PyMuPDF is missing

This commit is contained in:
red person
2026-06-01 12:27:17 +03:00
committed by GitHub
parent 5b1e56407b
commit 2f87dbcfbc
4 changed files with 61 additions and 3 deletions

15
src/pdf_runtime.py Normal file
View File

@@ -0,0 +1,15 @@
"""Small helpers for optional PDF runtime dependencies."""
PDF_VIEWER_PYMUPDF_MISSING = (
"PDF viewer requires PyMuPDF. Install optional PDF dependencies with "
"`pip install -r requirements-optional.txt` (PyMuPDF is AGPL-3.0)."
)
def load_pymupdf_for_pdf_viewer():
"""Return the PyMuPDF module, or raise a user-facing setup hint."""
try:
import fitz # PyMuPDF, optional
except ImportError as exc:
raise RuntimeError(PDF_VIEWER_PYMUPDF_MISSING) from exc
return fitz