Switch to opencv-python-headless, declare numpy explicitly - #3
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MultiClean's runtime uses exactly three OpenCV functions —
morphologyEx,connectedComponentsWithStatsanddistanceTransformWithLabels. 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:Given the remote-sensing / batch-processing audience, that failure mode is squarely in the path of normal use.
This PR:
opencv-python-headless.numpy>=1.21explicitly. It is imported directly inmulticlean/utils.pyandmulticlean/multiclean.pyand 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.>=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.0floor allowed a resolver to select.Verification
Full CI check set, run locally against a freshly synced environment:
ruff check .mypy multiclean/pytest tests/Confirmed only
opencv-python-headlessis installed — no duplicatecv2from 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.0pin 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<5cap to this PR.Both distributions provide the same
cv2module. If a downstream environment also needs the fullopencv-pythonbuild 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.lockis 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 perRELEASING.mdthat happens at tag time — no version edit in this PR.🤖 Generated with Claude Code