opencv-python: add build-opencv-python.yml for riscv64 wheels - #390
Merged
Conversation
Builds the OpenCV 5.0.0.93 Python bindings from an upstream checkout with cibuildwheel. setup.py always configures -DPYTHON3_LIMITED_API=ON, so a single cp37-abi3 wheel (built on cp312, matching upstream's own `setup.py bdist_wheel --py-limited-api=cp37`) covers every CPython and is reused to run the tests on 3.13 and 3.14. Upstream tags releases by build number alone, and derives the package version from the OpenCV sources plus `git describe`; the workflow maps 5.0.0.93 to tag 93, stamps cv2/version.py on the host and then drops the git repositories so the container build runs no git at all. Upstream's CI_BUILD=1 path links Qt5 and bundles DejaVu fonts from their own manylinux image; neither is packaged for riscv64, so it is left off and highgui is built without a GUI backend. Tests mirror upstream's scripts/install.sh: tests/get_build_info.py plus OpenCV's own python suite (`modules/python/test/test.py --repo .`) with OPENCV_TEST_DATA_PATH pointing at the opencv_extra checkout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Adds
.github/workflows/build-opencv-python.yml, building the OpenCV 5.0.0.93 Python bindings for riscv64.Shape — build-from-checkout with cibuildwheel.
setup.pyalways configures-DPYTHON3_LIMITED_API=ON, and upstream builds withsetup.py bdist_wheel --py-limited-api=cp37, so PyPI carries a singlecp37-abi3wheel per platform. We inject the same flag viaCIBW_CONFIG_SETTINGSand let cibuildwheel reuse that one wheel to run the tests on 3.13 and 3.14. Upstream publishes no free-threaded wheel, so there is nocp314tentry.Version mapping — upstream tags a release by its build number alone (
5.0.0.93is tag93), andfind_version.pyderives the package version fromopencv/modules/core/include/opencv2/core/version.hppplusgit describe. The workflow keeps the plain PyPI version as the input (so the nightly PyPI check works), maps it to the tag, stampscv2/version.pyon the host and asserts it matches, then removes the git repositories — the container build then runs no git at all, and cibuildwheel copies ~1 GB less into it.Divergence from upstream — upstream builds inside their own
quay.io/opencv-ci/opencv-python-manylinux*image, which adds Qt 5.15, ffmpeg, libvpx, aom and libavif.CI_BUILD=1unconditionally links Qt5 and bundles DejaVu fonts from that image, neither of which is packaged for riscv64, so it is left unset and highgui is built without a GUI backend. Everything else (MAKEFLAGS=-j$(nproc),--py-limited-api=cp37) mirrorstravis_config.sh.Testing mirrors
scripts/install.sh:tests/get_build_info.py, then OpenCV's own Python suite (modules/python/test/test.py -v --repo .) withOPENCV_TEST_DATA_PATHpointing at anopencv_extracheckout at the pinned submodule commit.riscv64 fix —
CMAKE_ARGS=-DPNG_RISCV_RVV=off. OpenCV's bundled libpng defaultsPNG_RISCV_RVVtoCPU_RVV_SUPPORTED, which OpenCV sets from a-march=rv64gc_vdispatch probe (HAVE_CXX_MARCH_RV64GC_V - Success, while the baselineHAVE_CPU_RVV_SUPPORTfails). libpng then re-probesriscv_vector.hwith the baseline flags, getsCOMPILER_SUPPORTS_RVV - Failed, and callsmessage(FATAL_ERROR ...), so configure dies. It also appendsriscv/filter_rvv_intrinsics.cwithout setting any-marchon those sources, so the path could not compile even if the probe passed —offis libpng's own documented default.CI — run 32914911908 is green: one
opencv_python-5.0.0.93-cp37-abi3-manylinux_2_39_riscv64.whl(16.4 MB) built on cp312 in ~2 h, reused by cibuildwheel for cp313 and cp314 (Found previously built wheel ... Skipping build step). OpenCV's Python suite ran on all three:Ran 155 tests ... OK (skipped=10)each time.publishdry-ran cleanly —Dry run (not on main branch — no upload will happen)/Would upload 1 file(s).