Skip to content

Use pymupdf-lite: pymupdf 2.0 pulls heavy dependencies (onnxruntime, numpy, ...) #372

Closed

Description

@benoit74

pymupdf 2.0 now hard-depends on many heavy packages, while 1.28.x had no dependency at all:

networkx, numpy, onnxruntime, pyyaml, pymupdf-layout==2.0, psutil, tabulate, pymupdf4llm==2.0

zimscraperlib only uses pymupdf to open PDFs and extract their text / metadata (zim/indexing.py), so pulling onnxruntime and numpy (hundreds of MB) into every scraper image is not acceptable.

Additionally, onnxruntime has no Python 3.15 wheel yet, so on Python 3.15 pip silently falls back to pymupdf 1.28.2.

For now, pymupdf is going to be pinned to <2.0, in 5.5.1 (for Python 3.14) and in the upcoming Python 3.15 / libzim 4 version.

To revisit when:

  • pymupdf makes these dependencies optional (extras) or ships a lean variant of 2.x
  • or 1.x stops receiving fixes, especially security ones (2.0 fixed CVE-2026-82035, in its CLI font extraction which we do not use)

Activity

  1. modified the milestones: 6.0.0, backlog on Oct 29, 2026
  2. added theissue type on Oct 29, 2026
  3. benoit74 commented on Oct 29, 2026

    @benoit74
    CollaboratorAuthor

    Artifex publishes an official lean variant: pymupdf-lite, built from the same pymupdf/PyMuPDF repository, which is "a cut-down version of PyMuPDF without the PyMuPDF Layout engine".

    Findings:

    • no dependency at all, 25.8 MB wheel, vs 68.9 MB for pymupdf 2.0 plus its onnxruntime, numpy, networkx, pymupdf4llm, pymupdf-layout, ... dependencies
    • abi3 wheels for Python 3.11 to 3.15 (so Python 3.15 is supported out of the box, unlike pymupdf 2.0 whose onnxruntime dependency has no 3.15 wheel)
    • drop-in replacement: it installs the very same pymupdf (and fitz) package, the full pymupdf wheel only adds pymupdf/layout/*, _features.so, _tgif.so and pymupdf4llm, none of which we use (we only open documents and extract their text and metadata)
    • full test suite passes with pymupdf-lite>=2.0,<3.0 on both Python 3.14 (main) and Python 3.15 (Support only Python 3.15, with libzim 4 #374), with no other package pulled

    Caveat: since both distributions install the same pymupdf package, a scraper also depending on the full pymupdf must keep both at the same version, and uninstalling one of them removes the files of the other (import pymupdf then fails while pymupdf-lite is still listed as installed). Fresh installs (e.g. scrapers Docker images) are not affected.

    Plan: depend on pymupdf-lite>=2.0,<3.0 instead of pinning pymupdf<2.0, in #373 (5.5.1, Python 3.14) and #374 (6.0.0, Python 3.15). This issue will be closed by #373.

  4. changed the title [-]pymupdf 2.0 pulls heavy dependencies (onnxruntime, numpy, ...)[/-] [+]Use pymupdf-lite: pymupdf 2.0 pulls heavy dependencies (onnxruntime, numpy, ...)[/+] on Oct 29, 2026
  5. added a commit that references this issue on Oct 29, 2026
    ff2aff4
  6. self-assigned this
    on Oct 29, 2026
  7. modified the milestones: backlog, 5.5.1 on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions