Skip to content

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

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

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

Conversation

@luhenry

@luhenry luhenry commented Aug 26, 2026

Copy link
Copy Markdown
Member

Adds .github/workflows/build-opencv-python-headless.yml, building the headless OpenCV 5.0.0.93 Python bindings for riscv64.

Shape — the headless distribution is not a separate project: it is the same opencv/opencv-python tree built with ENABLE_HEADLESS=1, which makes setup.py name the package opencv_python_headless and append -DWITH_QT=OFF -DWITH_GTK=OFF -DWITH_MSMF=OFF -DWITH_OBSENSOR=OFF -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=OFF. The workflow therefore mirrors the merged build-opencv-python.yml (#390) rather than inventing a second recipe: build-from-checkout with cibuildwheel, one cp37-abi3 wheel (upstream always configures -DPYTHON3_LIMITED_API=ON and builds --py-limited-api=cp37, injected here via CIBW_CONFIG_SETTINGS) built on cp312 and reused to test 3.13 and 3.14. Upstream publishes no free-threaded wheel, so there is no cp314t entry.

The one non-obvious bitsetup.py calls get_and_set_info(), which regenerates cv2/version.py only when .git exists and otherwise reads back headless from that file, overwriting whatever ENABLE_HEADLESS said. Since the workflow removes the git repositories before the build (to keep ~1 GB out of the container), the flag has to be set in both places: find_version.py False True False False at the stamp step, asserted with grep -Fqx "headless = True", and ENABLE_HEADLESS=1 in CIBW_ENVIRONMENT.

Version mapping — unchanged from #390: upstream tags a release by its build number alone (5.0.0.93 is tag 93), the plain PyPI version stays the workflow input so the nightly PyPI check works, and the tag is derived from it.

riscv64 fixCMAKE_ARGS=-DPNG_RISCV_RVV=off, same as #390: OpenCV's bundled libpng defaults PNG_RISCV_RVV to CPU_RVV_SUPPORTED, which OpenCV sets from a -march=rv64gc_v dispatch probe; libpng then re-probes the intrinsics with the baseline flags, fails, and message(FATAL_ERROR ...).

Divergence from upstream — upstream builds inside quay.io/opencv-ci/opencv-python-manylinux*, which is not published for riscv64; CI_BUILD is left unset. For the headless build that costs nothing that headless would have kept — the CI_BUILD branch that links Qt5 and bundles DejaVu fonts is itself gated on not build_headless.

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.

CI is starting from the pull_request trigger; the sibling non-headless build takes ~2 h per run.

CIrun 32965920143 is green: one opencv_python_headless-5.0.0.93-cp37-abi3-manylinux_2_39_riscv64.whl (16.4 MB) built on cp312 in ~2 h and reused for cp313/cp314 (Found previously built wheel ... Skipping build step). abi3audit --strict reports cv2.abi3.so is_abi3: true, baseline 3.7. Configure logs GUI: NONE with -DWITH_QT=OFF -DWITH_GTK=OFF -DWITH_MSMF=OFF -DWITH_OBSENSOR=OFF -DOPENCV_FFMPEG_ENABLE_LIBAVDEVICE=OFF, i.e. the headless flags did reach cmake. OpenCV's Python suite ran on all three interpreters: 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).

…v64 wheels

The headless variant is the same opencv/opencv-python build with
ENABLE_HEADLESS=1, so the workflow mirrors build-opencv-python.yml.

Without .git the stamped cv2/version.py is what setup.py reads back for
the package name, so the headless flag has to be set both at the stamp
(find_version.py False True False False) and in the container env.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@luhenry
luhenry merged commit 72465c4 into main Aug 26, 2026
6 checks passed
@luhenry
luhenry deleted the opencv-python-headless branch August 26, 2026 14:18
@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-headless riscv64 support

1 participant