From ff2aff4ad6bbad97a8e2b714f8bbf0712fa99bfa Mon Sep 17 00:00:00 2001 From: benoit74 Date: Thu, 29 Oct 2026 13:15:46 +0000 Subject: [PATCH] Depend on pymupdf-lite instead of pymupdf pymupdf 2.0 hard-depends on onnxruntime, numpy, networkx, pymupdf-layout, pymupdf4llm and more, pulled into every scraper. pymupdf-lite is the official build of the same pymupdf module without the layout engine, and without any dependency. Fix #372 --- CHANGELOG.md | 4 ++++ pyproject.toml | 4 +++- src/zimscraperlib/zim/indexing.py | 7 +------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a786f..098a23d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Depend on `pymupdf-lite` instead of `pymupdf`: same `pymupdf` module, without pymupdf 2.0 layout engine and the heavy dependencies (onnxruntime, numpy, ...) it pulled into every scraper; a scraper also depending on the full `pymupdf` must keep both at the same version (#372) + ## [5.5.0] - 2026-10-29 ### Added diff --git a/pyproject.toml b/pyproject.toml index 5e65102..5b9cb15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,9 @@ dependencies = [ # promise is that they will never (or always) break the API, and the API is very # limited and we use only a very small subset of it. "regex>=2020.7.14", - "pymupdf>=1.24.0,<3.0", + # pymupdf-lite is the official build of pymupdf without its layout engine, and + # without the heavy dependencies (onnxruntime, numpy, ...) it brings since 2.0 + "pymupdf-lite>=2.0,<3.0", "CairoSVG>=2.2.0,<3.0", "beartype>=0.19,<0.24", # youtube-dl should be updated as frequently as possible diff --git a/src/zimscraperlib/zim/indexing.py b/src/zimscraperlib/zim/indexing.py index e1b0c01..24e0412 100644 --- a/src/zimscraperlib/zim/indexing.py +++ b/src/zimscraperlib/zim/indexing.py @@ -4,12 +4,7 @@ import pathlib import libzim.writer # pyright: ignore[reportMissingModuleSource] - -try: - import pymupdf # pyright: ignore[reportMissingTypeStubs] -except ImportError: # pragma: no cover - # pymupdf main module was named fitz before 1.24.3 - import fitz as pymupdf # pyright: ignore[reportMissingTypeStubs] +import pymupdf # pyright: ignore[reportMissingTypeStubs] from zimscraperlib import logger