|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on: https://github.com/jax-ml/ml_dtypes/blob/v0.6.0/.github/workflows/wheels.yml |
| 5 | +name: Build ml-dtypes wheels (riscv64) |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + version: |
| 11 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/ml-dtypes.yaml not released yet' |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + pull_request: |
| 15 | + branches: [main] |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-ml-dtypes.yml' |
| 18 | + - 'docs/packages/ml-dtypes.yaml' |
| 19 | + push: |
| 20 | + branches: [main] |
| 21 | + paths: |
| 22 | + - '.github/workflows/build-ml-dtypes.yml' |
| 23 | + - 'docs/packages/ml-dtypes.yaml' |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: read # to fetch code (actions/checkout) |
| 31 | + |
| 32 | +env: |
| 33 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 34 | + |
| 35 | +jobs: |
| 36 | + setup: |
| 37 | + uses: $/.github/workflows/_setup.yml |
| 38 | + with: |
| 39 | + package: ml-dtypes |
| 40 | + version: ${{ inputs.version }} |
| 41 | + |
| 42 | + build_wheels: |
| 43 | + needs: [setup] |
| 44 | + if: needs.setup.outputs.versions != '[]' |
| 45 | + name: Build ml-dtypes ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 46 | + runs-on: ubuntu-24.04-riscv |
| 47 | + timeout-minutes: 120 |
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 52 | + python: |
| 53 | + - "cp312" |
| 54 | + - "cp313" |
| 55 | + - "cp314" |
| 56 | + - "cp314t" |
| 57 | + |
| 58 | + env: |
| 59 | + ML_DTYPES_VERSION: ${{ matrix.version }} |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout ml_dtypes ${{ env.ML_DTYPES_VERSION }} |
| 63 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 64 | + with: |
| 65 | + repository: jax-ml/ml_dtypes |
| 66 | + ref: v${{ env.ML_DTYPES_VERSION }} |
| 67 | + # third_party/eigen is a submodule and the extension compiles against it. |
| 68 | + submodules: recursive |
| 69 | + persist-credentials: false |
| 70 | + |
| 71 | + - name: Build wheels |
| 72 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 73 | + with: |
| 74 | + output-dir: wheelhouse/ |
| 75 | + only: ${{ matrix.python }}-manylinux_riscv64 |
| 76 | + env: |
| 77 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 78 | + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ PIP_ONLY_BINARY=numpy |
| 79 | + CIBW_TEST_REQUIRES: absl-py pytest pytest-xdist |
| 80 | + # riscv64's FP-invalid status flag diverges on casts between ml_dtypes' |
| 81 | + # non-IEEE custom float types (same class of divergence the project's own |
| 82 | + # CMakeLists.txt documents for Mac ARM); ml_dtypes' filterwarnings=error |
| 83 | + # promotes it to a hard failure even though the underlying assertions pass. |
| 84 | + CIBW_TEST_COMMAND: pytest -n auto -W "ignore:invalid value encountered in cast:RuntimeWarning" {project} |
| 85 | + |
| 86 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 87 | + with: |
| 88 | + name: ml-dtypes-${{ env.ML_DTYPES_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 89 | + path: wheelhouse/*.whl |
| 90 | + if-no-files-found: error |
| 91 | + |
| 92 | + eigen_sources: |
| 93 | + needs: [setup] |
| 94 | + if: needs.setup.outputs.versions != '[]' |
| 95 | + name: Collect eigen sources |
| 96 | + runs-on: ubuntu-latest |
| 97 | + strategy: |
| 98 | + fail-fast: false |
| 99 | + matrix: |
| 100 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 101 | + |
| 102 | + env: |
| 103 | + ML_DTYPES_VERSION: ${{ matrix.version }} |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout ml_dtypes ${{ env.ML_DTYPES_VERSION }} |
| 107 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 108 | + with: |
| 109 | + repository: jax-ml/ml_dtypes |
| 110 | + ref: v${{ env.ML_DTYPES_VERSION }} |
| 111 | + submodules: recursive |
| 112 | + persist-credentials: false |
| 113 | + |
| 114 | + # The extension compiles MPL-2.0 eigen headers into the wheel, so the |
| 115 | + # matching sources are published next to it. |
| 116 | + - run: tar cf gpl-sources.tar third_party/eigen |
| 117 | + |
| 118 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 119 | + with: |
| 120 | + name: ml-dtypes-${{ env.ML_DTYPES_VERSION }}-gpl-sources |
| 121 | + path: gpl-sources.tar |
| 122 | + if-no-files-found: error |
| 123 | + |
| 124 | + publish: |
| 125 | + name: Publish ml-dtypes ${{ matrix.version }} |
| 126 | + needs: [setup, build_wheels, eigen_sources] |
| 127 | + if: needs.setup.outputs.versions != '[]' |
| 128 | + strategy: |
| 129 | + fail-fast: false |
| 130 | + matrix: |
| 131 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 132 | + permissions: |
| 133 | + contents: write |
| 134 | + pull-requests: write |
| 135 | + uses: $/.github/workflows/_publish-wheel.yml |
| 136 | + with: |
| 137 | + artifact-pattern: ml-dtypes-${{ matrix.version }}-*-manylinux_riscv64 |
| 138 | + gpl-sources-artifact: ml-dtypes-${{ matrix.version }}-gpl-sources |
| 139 | + gpl-sources-description: eigen (MPL-2.0) |
0 commit comments