Skip to content

opencv-python: add build-opencv-python.yml for riscv64 wheels - #390

Merged
luhenry merged 1 commit into
mainfrom
opencv-python
Aug 26, 2026
Merged

opencv-python: add build-opencv-python.yml for riscv64 wheels#390
luhenry merged 1 commit into
mainfrom
opencv-python

Conversation

@luhenry

@luhenry luhenry commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.py always configures -DPYTHON3_LIMITED_API=ON, and upstream builds with setup.py bdist_wheel --py-limited-api=cp37, so PyPI carries a single cp37-abi3 wheel per platform. We inject the same flag via CIBW_CONFIG_SETTINGS and 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 no cp314t entry.

Version mapping — upstream tags a release by its build number alone (5.0.0.93 is tag 93), and find_version.py derives the package version from opencv/modules/core/include/opencv2/core/version.hpp plus git describe. The workflow keeps the plain PyPI version as the input (so the nightly PyPI check works), maps it to the tag, stamps cv2/version.py on 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=1 unconditionally 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) mirrors travis_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 .) with OPENCV_TEST_DATA_PATH pointing at an opencv_extra checkout at the pinned submodule commit.

riscv64 fixCMAKE_ARGS=-DPNG_RISCV_RVV=off. OpenCV's bundled libpng defaults PNG_RISCV_RVV to CPU_RVV_SUPPORTED, which OpenCV sets from a -march=rv64gc_v dispatch probe (HAVE_CXX_MARCH_RV64GC_V - Success, while the baseline HAVE_CPU_RVV_SUPPORT fails). libpng then re-probes riscv_vector.h with the baseline flags, gets COMPILER_SUPPORTS_RVV - Failed, and calls message(FATAL_ERROR ...), so configure dies. It also appends riscv/filter_rvv_intrinsics.c without setting any -march on those sources, so the path could not compile even if the probe passed — off is libpng's own documented default.

CIrun 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. publish dry-ran cleanly — Dry run (not on main branch — no upload will happen) / Would upload 1 file(s).

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>
@luhenry
luhenry merged commit dce1c83 into main Aug 26, 2026
7 checks passed
@luhenry
luhenry deleted the opencv-python branch August 26, 2026 10:40
@luhenry luhenry linked an issue Aug 26, 2026 that may be closed by this pull request
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.

opencv-python riscv64 support

1 participant