From 8512e2ba0c27806c7b91fa10f1a1a2a3940c8984 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sat, 26 Sep 2026 00:54:43 +0000 Subject: [PATCH] chiavdf: add build-chiavdf.yml for riscv64 wheels --- .github/workflows/build-chiavdf.yml | 184 ++++++++++++++++++++++++++++ docs/packages/chiavdf.yaml | 5 + 2 files changed, 189 insertions(+) create mode 100644 .github/workflows/build-chiavdf.yml create mode 100644 docs/packages/chiavdf.yaml diff --git a/.github/workflows/build-chiavdf.yml b/.github/workflows/build-chiavdf.yml new file mode 100644 index 00000000000..36548ad2d84 --- /dev/null +++ b/.github/workflows/build-chiavdf.yml @@ -0,0 +1,184 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# Based on: https://github.com/Chia-Network/chiavdf/blob/1.1.14/.github/workflows/build.yml +name: Build chiavdf wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/chiavdf.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-chiavdf.yml' + - 'docs/packages/chiavdf.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-chiavdf.yml' + - 'docs/packages/chiavdf.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + GMP_VERSION: '6.2.1' + GMP_SHA256: 'fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2' + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: chiavdf + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build chiavdf ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 360 + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + python: ["cp312", "cp313", "cp314"] + + env: + CHIAVDF_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout chiavdf ${{ env.CHIAVDF_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: Chia-Network/chiavdf + ref: ${{ env.CHIAVDF_VERSION }} + persist-credentials: false + + # GMP and pybind11 are linked into the wheel; upstream ships neither notice. + - name: Fetch GMP and stage the bundled dependencies' licences + run: | + set -euo pipefail + curl -fsSL --retry 5 "https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz" -o "gmp-${GMP_VERSION}.tar.xz" + echo "${GMP_SHA256} gmp-${GMP_VERSION}.tar.xz" | sha256sum -c - + tar xJf "gmp-${GMP_VERSION}.tar.xz" --to-stdout "gmp-${GMP_VERSION}/COPYING.LESSERv3" "gmp-${GMP_VERSION}/COPYINGv3" > LICENSE.gmp + pybind11=$(sed -n '/GIT_REPOSITORY .*\/pybind11\.git/{n;s/.*GIT_TAG *//p}' src/CMakeLists.txt) + curl -fsSL --retry 5 "https://raw.githubusercontent.com/pybind/pybind11/${pybind11}/LICENSE" -o LICENSE.pybind11 + + - uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + only: ${{ matrix.python }}-manylinux_riscv64 + env: + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # manylinux has no EPEL on riscv64 and Rocky 10 has no lzip, so GMP comes from the .tar.xz fetched above. + CIBW_BEFORE_ALL: >- + yum -y install boost-devel + && tar xJf gmp-${{ env.GMP_VERSION }}.tar.xz + && cp src/lib/gmp-patch-6.2.1/longlong.h gmp-${{ env.GMP_VERSION }}/ + && cp src/lib/gmp-patch-6.2.1/compat.c gmp-${{ env.GMP_VERSION }}/ + && cp src/lib/gmp-patch-6.2.1/mpz/inp_raw.c gmp-${{ env.GMP_VERSION }}/mpz + && cd gmp-${{ env.GMP_VERSION }} && ./configure --enable-fat --enable-cxx + && make && make install && cd .. && rm -rf gmp-${{ env.GMP_VERSION }} + && cmake --version + && uname -a + + - name: Check wheel contents + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + names = zipfile.ZipFile(sys.argv[1]).namelist() + exts = [n for n in names if n.endswith(".so")] + assert len(exts) == 1 and exts[0].startswith("chiavdf.cpython-"), exts + assert exts[0].endswith("-riscv64-linux-gnu.so"), exts + libs = {n.split("/")[-1].split("-")[0] for n in names if n.startswith("chiavdf.libs/") and not n.endswith("/")} + assert libs == {"libgmp", "libgmpxx"}, libs + licences = {n.split(".dist-info/licenses/", 1)[1] for n in names + if ".dist-info/licenses/" in n and not n.endswith("/")} + assert licences == {"LICENSE", "LICENSE.gmp", "LICENSE.pybind11"}, licences + EOF + + - name: Store wheels + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: chiavdf-${{ env.CHIAVDF_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + gpl_sources: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + name: Collect GPL sources + runs-on: ubuntu-24.04-riscv + + env: + CHIAVDF_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./actions/collect-gpl-sources + with: + image: ${{ env.MANYLINUX_RISCV64_IMAGE }} + packages: gcc + output: rpm-gpl-sources.tar + + - name: Checkout chiavdf ${{ env.CHIAVDF_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: Chia-Network/chiavdf + ref: ${{ env.CHIAVDF_VERSION }} + path: chiavdf + persist-credentials: false + + # The bundled GMP is the pristine release plus chiavdf's replacement files. + - name: Combine GPL sources into one archive + run: | + set -euo pipefail + mkdir gpl-sources + tar xf rpm-gpl-sources.tar -C gpl-sources + curl -fsSL --retry 5 "https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz" -o "gpl-sources/gmp-${GMP_VERSION}.tar.xz" + echo "${GMP_SHA256} gpl-sources/gmp-${GMP_VERSION}.tar.xz" | sha256sum -c - + cp -r chiavdf/src/lib/gmp-patch-6.2.1 gpl-sources/ + tar cf gpl-sources.tar -C gpl-sources . + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: chiavdf-${{ env.CHIAVDF_VERSION }}-gpl-sources + path: gpl-sources.tar + if-no-files-found: error + + publish: + name: Publish chiavdf ${{ matrix.version }} + needs: [setup, build_wheels, gpl_sources] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: chiavdf-${{ matrix.version }}-*-manylinux_riscv64 + gpl-sources-artifact: chiavdf-${{ matrix.version }}-gpl-sources + gpl-sources-description: gcc, gmp diff --git a/docs/packages/chiavdf.yaml b/docs/packages/chiavdf.yaml new file mode 100644 index 00000000000..b4a2ef8bc1a --- /dev/null +++ b/docs/packages/chiavdf.yaml @@ -0,0 +1,5 @@ +package-name: chiavdf +source-code: https://github.com/Chia-Network/chiavdf +license: Apache-2.0 +versions: +- version: 1.1.14