|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# Based on the `build_wheels` job of |
| 5 | +# https://github.com/project-gemmi/gemmi/blob/v0.7.5/.github/workflows/wheels2.yml |
| 6 | +name: Build gemmi wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'gemmi version/tag to build (git tag without leading v, e.g. 0.7.5)' |
| 13 | + required: true |
| 14 | + default: '0.7.5' |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-gemmi.yml' |
| 18 | + - 'patches/gemmi/**' |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ inputs.version || '0.7.5' }}-${{ github.head_ref || github.run_id }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: read # to fetch code (actions/checkout) |
| 26 | + |
| 27 | +env: |
| 28 | + GEMMI_VERSION: ${{ inputs.version || '0.7.5' }} |
| 29 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 30 | + MUSLLINUX_RISCV64_IMAGE: quay.io/pypa/musllinux_1_2_riscv64 |
| 31 | + |
| 32 | +jobs: |
| 33 | + setup: |
| 34 | + uses: $/.github/workflows/_setup.yml |
| 35 | + |
| 36 | + build_wheels: |
| 37 | + needs: [setup] |
| 38 | + name: Build gemmi ${{ inputs.version || '0.7.5' }} ${{ matrix.python }}-${{ matrix.libc }}_riscv64 |
| 39 | + runs-on: ubuntu-24.04-riscv |
| 40 | + timeout-minutes: 120 |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + python: ["cp312", "cp313", "cp314", "cp314t"] |
| 45 | + libc: [manylinux, musllinux] |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout gemmi v${{ env.GEMMI_VERSION }} |
| 49 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 50 | + with: |
| 51 | + repository: project-gemmi/gemmi |
| 52 | + ref: v${{ env.GEMMI_VERSION }} |
| 53 | + persist-credentials: false |
| 54 | + |
| 55 | + - name: Checkout python-wheels |
| 56 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 57 | + with: |
| 58 | + path: python-wheels |
| 59 | + persist-credentials: false |
| 60 | + |
| 61 | + # stb_sprintf.h has no riscv64 entry in its 64-bit-pointer-arch allowlist. |
| 62 | + - name: Patch gemmi source |
| 63 | + run: git apply python-wheels/patches/gemmi/${{ env.GEMMI_VERSION }}/00*.patch |
| 64 | + |
| 65 | + - uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 66 | + env: |
| 67 | + CIBW_ARCHS: riscv64 |
| 68 | + CIBW_BUILD: ${{ matrix.python }}-${{ matrix.libc }}_riscv64 |
| 69 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 70 | + CIBW_MUSLLINUX_RISCV64_IMAGE: ${{ env.MUSLLINUX_RISCV64_IMAGE }} |
| 71 | + # find_package(nanobind 2.4.0) in CMakeLists.txt rejects nanobind 3.x as |
| 72 | + # incompatible; pyproject.toml's build-system.requires has no upper bound. |
| 73 | + CIBW_BEFORE_ALL: echo 'nanobind<3' > /nanobind-constraint.txt |
| 74 | + # The fetched zlib-ng's RVV chunkset/inflate kernels SIGILL on the first |
| 75 | + # gzipped file gemmi reads; fall back to its portable C implementation. |
| 76 | + CIBW_ENVIRONMENT: >- |
| 77 | + SKBUILD_CMAKE_ARGS='-DBUILD_GEMMI_PROGRAM=OFF;-DINSTALL_DEV_FILES=OFF;-DBUILD_SHARED_LIBS=OFF;-DFETCH_ZLIB_NG=ON;-DWITH_RVV=OFF' |
| 78 | + PIP_CONSTRAINT=/nanobind-constraint.txt |
| 79 | + PIP_BUILD_CONSTRAINT=/nanobind-constraint.txt |
| 80 | +
|
| 81 | + - name: Check wheel contents |
| 82 | + run: | |
| 83 | + python3 - wheelhouse/*.whl <<'EOF' |
| 84 | + import sys, zipfile |
| 85 | + path = sys.argv[1] |
| 86 | + names = zipfile.ZipFile(path).namelist() |
| 87 | + exts = [n for n in names if n.endswith(".so")] |
| 88 | + assert exts and all("gemmi_ext" in n for n in exts), exts |
| 89 | + licences = {n.split(".dist-info/licenses/", 1)[1] for n in names |
| 90 | + if ".dist-info/licenses/" in n and not n.endswith("/")} |
| 91 | + assert licences == {"LICENSE.txt"}, licences |
| 92 | + EOF |
| 93 | +
|
| 94 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 95 | + with: |
| 96 | + name: gemmi-${{ env.GEMMI_VERSION }}-${{ matrix.python }}-${{ matrix.libc }}_riscv64 |
| 97 | + path: ./wheelhouse/*.whl |
| 98 | + if-no-files-found: error |
| 99 | + |
| 100 | + publish: |
| 101 | + name: Publish gemmi ${{ inputs.version || '0.7.5' }} |
| 102 | + needs: [setup, build_wheels] |
| 103 | + permissions: |
| 104 | + contents: write |
| 105 | + pull-requests: write |
| 106 | + uses: $/.github/workflows/_publish-wheel.yml |
| 107 | + with: |
| 108 | + artifact-pattern: gemmi-${{ inputs.version || '0.7.5' }}-*riscv64 |
0 commit comments