From 85080c8ed5dad111295ee13fdd168182c397fe4c Mon Sep 17 00:00:00 2001 From: AngeloDanducci Date: Thu, 10 Sep 2026 14:37:08 -0400 Subject: [PATCH] fix: pin pillow to exclude broken 12.3.0 release Signed-off-by: AngeloDanducci --- pyproject.toml | 2 +- test/package/test_pillow_constraint.py | 41 ++++++++++++++++++++++++++ uv.lock | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 test/package/test_pillow_constraint.py diff --git a/pyproject.toml b/pyproject.toml index b0518c04de..388705a76f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "ollama>=0.5.1", "requests>=2.32.3", "mistletoe>=1.4.0", - "pillow>=12.0.0", # Needed for Intrinsics (HF and OpenAI Backends). + "pillow>=12.2.0,!=12.3.0", # Needed for Intrinsics (HF and OpenAI Backends). 12.3.0 removed PIL._typing._Ink, breaking docling (issue#1640). "math_verify", # Needed for Majority Voting Sampling Strategies. "nltk>=3.9,!=3.10.1", # Needed for sentence tokenization in granite citation parsing. "rouge_score", # Needed for Majority Voting Sampling Strategies. diff --git a/test/package/test_pillow_constraint.py b/test/package/test_pillow_constraint.py new file mode 100644 index 0000000000..8f9a7976c9 --- /dev/null +++ b/test/package/test_pillow_constraint.py @@ -0,0 +1,41 @@ +# Copyright IBM Corp. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Tests that the core `pillow` dependency specifier excludes the broken 12.3.0 release. + +Pillow 12.3.0 removed `_Ink` from `PIL._typing`, which breaks `from PIL import +ImageText` and cascades through `docling_core` into `RichDocument` (issue #1640). +These tests assert the specifier in `pyproject.toml` cannot resolve 12.3.0 while +still admitting the known-good releases. +""" + +from __future__ import annotations + +import tomllib +from pathlib import Path + +from packaging.requirements import Requirement + +PYPROJECT = Path(__file__).resolve().parents[2] / "pyproject.toml" + + +def _pillow_specifier(): + """Return the `SpecifierSet` for the core `pillow` dependency in pyproject.toml.""" + with PYPROJECT.open("rb") as f: + pyproject = tomllib.load(f) + for dep in pyproject["project"]["dependencies"]: + req = Requirement(dep) + if req.name == "pillow": + return req.specifier + raise AssertionError("pillow not found in core dependencies") + + +def test_pillow_specifier_excludes_broken_1230(): + """The pillow specifier must not admit the broken 12.3.0 release (issue #1640).""" + assert "12.3.0" not in _pillow_specifier() + + +def test_pillow_specifier_allows_working_versions(): + """The pillow specifier still admits the known-good 12.2.0 release.""" + spec = _pillow_specifier() + assert "12.2.0" in spec diff --git a/uv.lock b/uv.lock index 95db1abe90..c95dd188e9 100644 --- a/uv.lock +++ b/uv.lock @@ -3465,7 +3465,7 @@ requires-dist = [ { name = "opentelemetry-sdk", marker = "extra == 'telemetry'", specifier = ">=1.20.0" }, { name = "packaging" }, { name = "peft", marker = "extra == 'hf'", specifier = ">=0.18.1" }, - { name = "pillow", specifier = ">=12.0.0" }, + { name = "pillow", specifier = ">=12.2.0,!=12.3.0" }, { name = "pyarrow", marker = "extra == 'granite-retriever'" }, { name = "pydantic" }, { name = "pyyaml" },