Skip to content

Switch to opencv-python-headless, declare numpy explicitly - #3

Merged
wrignj08 merged 1 commit into
mainfrom
deps/opencv-headless
Jul 28, 2026
Merged

Switch to opencv-python-headless, declare numpy explicitly#3
wrignj08 merged 1 commit into
mainfrom
deps/opencv-headless

Conversation

@wrignj08

Copy link
Copy Markdown
Contributor

Summary

MultiClean's runtime uses exactly three OpenCV functions — morphologyEx, connectedComponentsWithStats and distanceTransformWithLabels. No highgui, no video I/O. The GUI build of OpenCV was therefore pulling in shared libraries we never call, which slim container and CI images do not ship, producing the classic:

ImportError: libGL.so.1: cannot open shared object file

Given the remote-sensing / batch-processing audience, that failure mode is squarely in the path of normal use.

This PR:

  • Switches the runtime dependency to opencv-python-headless.
  • Declares numpy>=1.21 explicitly. It is imported directly in multiclean/utils.py and multiclean/multiclean.py and appears in the public type signatures (np.ndarray), but was only ever installed transitively via OpenCV — we were relying on another package's dependency graph for something we import ourselves.
  • Raises the OpenCV floor to >=4.10. Builds before 4.10.0.84 are compiled against NumPy 1.x and fail at import when paired with NumPy 2.x, which the previous >=4.0 floor allowed a resolver to select.
 dependencies = [
-    "opencv-python>=4.0",
+    "opencv-python-headless>=4.10",
+    "numpy>=1.21",
 ]

Verification

Full CI check set, run locally against a freshly synced environment:

Check Result
ruff check . All checks passed
mypy multiclean/ Success, no issues in 3 source files
pytest tests/ 322 passed in 5.50s

Confirmed only opencv-python-headless is installed — no duplicate cv2 from both distributions.

Reviewer notes

Two things worth a deliberate decision rather than a rubber stamp:

The resolver picked OpenCV 5.0.0, not 4.x. The old opencv-python>=4.0 pin was holding us on the 4.x line in practice; changing the distribution name let the resolver cross a major version. All 322 tests pass on 5.0.0, so the three functions we use are stable across the boundary — but downstream users will get the same jump. If we'd rather not ship a major OpenCV bump alongside the headless switch, add a <5 cap to this PR.

Both distributions provide the same cv2 module. If a downstream environment also needs the full opencv-python build for other work, installing both means one clobbers the other's files. This is noted in the changelog entry for users. For a batch-processing library headless is the conventional default, but it is a downstream-visible change.

uv.lock is gitignored in this repo, so it is intentionally not part of this diff.

Release

This is a downstream-visible dependency change, so it warrants a minor version bump rather than a patch when tagged. Version is setuptools-scm-driven, so per RELEASING.md that happens at tag time — no version edit in this PR.

🤖 Generated with Claude Code

MultiClean only calls morphologyEx, connectedComponentsWithStats and
distanceTransformWithLabels — no GUI or video I/O — so the GUI build of
OpenCV was pulling in shared libraries that slim container and CI images
do not have, where it fails at import with:

    ImportError: libGL.so.1: cannot open shared object file

Switch the runtime dependency to opencv-python-headless.

Also declare numpy as an explicit runtime dependency. It is imported
directly in multiclean/utils.py and multiclean/multiclean.py and appears
in the public type signatures, but was only ever installed transitively
via OpenCV.

Raise the OpenCV floor to >=4.10. Builds before 4.10.0.84 are compiled
against NumPy 1.x and fail at import when paired with NumPy 2.x, which
the previous >=4.0 floor allowed a resolver to select.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@wrignj08
wrignj08 merged commit b113fd9 into main Jul 28, 2026
2 checks passed
@wrignj08 wrignj08 mentioned this pull request Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant