From 9db21dfc5f410bafb3729a62a4b7236442406459 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 8 Sep 2026 17:41:19 +0200 Subject: [PATCH] boost-histogram: add build-boost-histogram.yml for riscv64 wheels --- .github/workflows/build-boost-histogram.yml | 151 ++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 .github/workflows/build-boost-histogram.yml diff --git a/.github/workflows/build-boost-histogram.yml b/.github/workflows/build-boost-histogram.yml new file mode 100644 index 000000000..26d9d8caa --- /dev/null +++ b/.github/workflows/build-boost-histogram.yml @@ -0,0 +1,151 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on upstream's own wheel build setup: +# https://github.com/scikit-hep/boost-histogram/blob/v1.8.1/.github/workflows/wheels.yml +name: Build boost-histogram wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'boost-histogram version to build (git tag without leading v, e.g. 1.8.1)' + required: true + default: '1.8.1' + pull_request: + paths: + - '.github/workflows/build-boost-histogram.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '1.8.1' }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + # `inputs.version` is empty on pull_request events; default to 1.8.1 there. + BOOST_HISTOGRAM_VERSION: ${{ inputs.version || '1.8.1' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_sdist: + needs: [setup] + # The sdist packages the source tree plus the vendored Boost.Histogram/Core/Mp11/ + # Config/ThrowException/Assert/Variant2 headers (git submodules) and a + # setuptools-scm-derived version. It's architecture-independent, so build it once + # on x86 instead of burning a scarce riscv runner (CLAUDE.md gotcha 4). + name: Build boost-histogram ${{ inputs.version || '1.8.1' }} sdist + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + sdist_name: ${{ steps.sdist.outputs.sdist_name }} + package_version: ${{ steps.sdist.outputs.package_version }} + steps: + - name: Checkout boost-histogram v${{ env.BOOST_HISTOGRAM_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: scikit-hep/boost-histogram + ref: v${{ env.BOOST_HISTOGRAM_VERSION }} + submodules: recursive + fetch-depth: 0 + fetch-tags: true + persist-credentials: false + + - name: Install Python + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 + with: + python-version: '3.12' + activate-environment: true + enable-cache: false + + - name: Build sdist + id: sdist + run: | + uv pip install build twine + python -m build --sdist + twine check --strict dist/*.tar.gz + sdists=(dist/*.tar.gz) + echo "sdist_name=$(basename "${sdists[0]}")" >> "$GITHUB_OUTPUT" + echo "package_version=$(basename "${sdists[0]}" | sed -En 's/boost_histogram-(.+)\.tar\.gz/\1/p')" >> "$GITHUB_OUTPUT" + + - name: Upload sdist artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: boost-histogram-${{ env.BOOST_HISTOGRAM_VERSION }}-sdist + path: dist/*.tar.gz + if-no-files-found: error + + build_wheels: + needs: [setup, build_sdist] + name: Build boost-histogram ${{ inputs.version || '1.8.1' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + permissions: + contents: read + strategy: + fail-fast: false + matrix: + python: ["cp312", "cp313", "cp314", "cp314t"] + include: + # hypothesis (a test dependency) ships no riscv64 wheel for PyPI's + # newest release on the free-threaded ABI; our own registry's older + # build does. Widening UV_ONLY_BINARY doesn't help - uv's resolver + # still picks the newest version first and tries to build its sdist + # (which needs a Rust toolchain riscv64 lacks) rather than falling + # back to a version with a usable wheel, so pin the version instead. + - python: "cp314t" + test_requires: "hypothesis==6.165.10" + + steps: + - name: Download sdist + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: boost-histogram-${{ env.BOOST_HISTOGRAM_VERSION }}-sdist + path: dist/ + + - name: Build wheels + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + package-dir: dist/${{ needs.build_sdist.outputs.sdist_name }} + env: + CIBW_BUILD: ${{ matrix.python }}-* + CIBW_ARCHS: riscv64 + # numpy (a hard runtime dependency) ships no musllinux riscv64 wheel + # anywhere, so musllinux is dropped (workflow-anatomy.md: an accepted + # outcome). + CIBW_SKIP: '*-musllinux_*' + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # CIBW_ENVIRONMENT replaces, rather than merges into, upstream's own + # [tool.cibuildwheel] environment table (CLAUDE.md gotcha 107), so its + # four keys are repeated here alongside our registry. The test-install + # step resolves with uv, which only reads UV_* names, not PIP_* (CLAUDE.md + # gotcha 244), so both are set. + CIBW_ENVIRONMENT: >- + PIP_ONLY_BINARY=numpy + PIP_PREFER_BINARY=1 + UV_ONLY_BINARY=numpy + UV_PREFER_BINARY=1 + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + UV_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + UV_INDEX_STRATEGY=unsafe-best-match + CIBW_TEST_REQUIRES: ${{ matrix.test_requires }} + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: boost-histogram-${{ env.BOOST_HISTOGRAM_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish boost-histogram ${{ inputs.version || '1.8.1' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: boost-histogram-${{ inputs.version || '1.8.1' }}-*-manylinux_riscv64