|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on: https://github.com/cvxopt/cvxopt/blob/1.3.3/.github/workflows/linux_build.yml |
| 5 | +name: Build cvxopt 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/cvxopt.yaml not released yet' |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + pull_request: |
| 15 | + branches: [main] |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-cvxopt.yml' |
| 18 | + - 'docs/packages/cvxopt.yaml' |
| 19 | + push: |
| 20 | + branches: [main] |
| 21 | + paths: |
| 22 | + - '.github/workflows/build-cvxopt.yml' |
| 23 | + - 'docs/packages/cvxopt.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 | + # Rocky 10 has no SuiteSparse for riscv64, so umfpack/cholmod/amd are compiled |
| 35 | + # from source; version and hash are upstream's own pin (linux_build.yml). |
| 36 | + SUITESPARSE_VERSION: '7.11.0' |
| 37 | + SUITESPARSE_SHA256: '93ed4c4e546a49fc75884c3a8b807d5af4a91e39d191fbbc60a07380b12a35d1' |
| 38 | + |
| 39 | +jobs: |
| 40 | + setup: |
| 41 | + uses: $/.github/workflows/_setup.yml |
| 42 | + with: |
| 43 | + package: cvxopt |
| 44 | + version: ${{ inputs.version }} |
| 45 | + |
| 46 | + build_wheels: |
| 47 | + needs: [setup] |
| 48 | + if: needs.setup.outputs.versions != '[]' |
| 49 | + name: Build cvxopt ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 50 | + runs-on: ubuntu-24.04-riscv |
| 51 | + timeout-minutes: 180 |
| 52 | + strategy: |
| 53 | + fail-fast: false |
| 54 | + matrix: |
| 55 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 56 | + python: |
| 57 | + - "cp312" |
| 58 | + - "cp313" |
| 59 | + - "cp314" |
| 60 | + - "cp314t" |
| 61 | + |
| 62 | + env: |
| 63 | + CVXOPT_VERSION: ${{ matrix.version }} |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout cvxopt ${{ env.CVXOPT_VERSION }} |
| 67 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 68 | + with: |
| 69 | + repository: cvxopt/cvxopt |
| 70 | + ref: ${{ env.CVXOPT_VERSION }} |
| 71 | + fetch-depth: 0 |
| 72 | + persist-credentials: false |
| 73 | + |
| 74 | + - name: Build wheels |
| 75 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 76 | + with: |
| 77 | + output-dir: wheelhouse/ |
| 78 | + only: ${{ matrix.python }}-manylinux_riscv64 |
| 79 | + env: |
| 80 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 81 | + # Replaces upstream's before_all_linux.sh, which exits on any |
| 82 | + # architecture other than x86_64/i686/aarch64. |
| 83 | + CIBW_BEFORE_ALL_LINUX: >- |
| 84 | + dnf -y install openblas-devel fftw-devel && |
| 85 | + curl -fsSL -o /tmp/suitesparse.tar.gz https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v${{ env.SUITESPARSE_VERSION }}.tar.gz && |
| 86 | + echo "${{ env.SUITESPARSE_SHA256 }} /tmp/suitesparse.tar.gz" | sha256sum -c - && |
| 87 | + tar xzf /tmp/suitesparse.tar.gz -C {project} && |
| 88 | + cp {project}/SuiteSparse-${{ env.SUITESPARSE_VERSION }}/LICENSE.txt {project}/LICENSE.suitesparse && |
| 89 | + cp /usr/share/licenses/openblas/LICENSE {project}/LICENSE.openblas && |
| 90 | + cp /usr/share/licenses/fftw-libs-double/COPYING {project}/LICENSE.fftw |
| 91 | + # Upstream's own linux environment table, minus the gsl, glpk and dsdp |
| 92 | + # extensions (no riscv64 packages, and no EPEL for it either). The |
| 93 | + # *_LIB_DIR overrides are needed because setup.py only guesses |
| 94 | + # /usr/lib64 when it finds SuiteSparse installed there. |
| 95 | + CIBW_ENVIRONMENT: >- |
| 96 | + CVXOPT_BLAS_LIB=openblas |
| 97 | + CVXOPT_LAPACK_LIB=openblas |
| 98 | + CVXOPT_BLAS_LIB_DIR=/usr/lib64 |
| 99 | + CVXOPT_BUILD_FFTW=1 |
| 100 | + CVXOPT_FFTW_LIB_DIR=/usr/lib64 |
| 101 | + CVXOPT_SUITESPARSE_SRC_DIR=SuiteSparse-${{ env.SUITESPARSE_VERSION }} |
| 102 | +
|
| 103 | + - name: Check the wheel ships the extensions and all licences |
| 104 | + run: | |
| 105 | + python3 - wheelhouse/*.whl <<'EOF' |
| 106 | + import sys, zipfile |
| 107 | + for whl in sys.argv[1:]: |
| 108 | + names = zipfile.ZipFile(whl).namelist() |
| 109 | + for mod in ("base", "blas", "lapack", "umfpack", "cholmod", "amd", |
| 110 | + "misc_solvers", "fftw"): |
| 111 | + assert any(n.startswith(f"cvxopt/{mod}.") and n.endswith(".so") |
| 112 | + for n in names), (whl, mod) |
| 113 | + licences = {n.rsplit("/", 1)[1] |
| 114 | + for n in names if ".dist-info/licenses/" in n} - {""} |
| 115 | + assert licences == {"LICENSE", "LICENSE.openblas", "LICENSE.suitesparse", |
| 116 | + "LICENSE.fftw"}, (whl, licences) |
| 117 | + print(whl, "ok") |
| 118 | + EOF |
| 119 | +
|
| 120 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 121 | + with: |
| 122 | + name: cvxopt-${{ env.CVXOPT_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 123 | + path: wheelhouse/*.whl |
| 124 | + if-no-files-found: error |
| 125 | + |
| 126 | + gpl_sources: |
| 127 | + needs: [setup] |
| 128 | + if: needs.setup.outputs.versions != '[]' |
| 129 | + strategy: |
| 130 | + fail-fast: false |
| 131 | + matrix: |
| 132 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 133 | + name: Collect GPL sources |
| 134 | + runs-on: ubuntu-24.04-riscv |
| 135 | + |
| 136 | + env: |
| 137 | + CVXOPT_VERSION: ${{ matrix.version }} |
| 138 | + |
| 139 | + steps: |
| 140 | + - name: Checkout python-wheels |
| 141 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 142 | + with: |
| 143 | + persist-credentials: false |
| 144 | + |
| 145 | + # OpenBLAS is compiled with gfortran, so auditwheel vendors the image's |
| 146 | + # libgfortran alongside libfftw3 (GPL-2.0-or-later). |
| 147 | + - uses: ./actions/collect-gpl-sources |
| 148 | + with: |
| 149 | + image: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 150 | + packages: gcc fftw |
| 151 | + output: rpm-gpl-sources.tar |
| 152 | + |
| 153 | + # UMFPACK and CHOLMOD's supernodal module (GPL-2.0-or-later) are compiled |
| 154 | + # straight into the wheel from the pinned tarball, which is not in the |
| 155 | + # image's repos, so their source is collected here rather than as an RPM. |
| 156 | + - name: Fetch pinned SuiteSparse source |
| 157 | + run: | |
| 158 | + set -euo pipefail |
| 159 | + curl -fsSLO "https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v${SUITESPARSE_VERSION}.tar.gz" |
| 160 | + echo "${SUITESPARSE_SHA256} v${SUITESPARSE_VERSION}.tar.gz" | sha256sum -c - |
| 161 | +
|
| 162 | + - name: Combine GPL sources into one archive |
| 163 | + run: | |
| 164 | + set -euo pipefail |
| 165 | + mkdir gpl-sources |
| 166 | + tar xf rpm-gpl-sources.tar -C gpl-sources |
| 167 | + cp "v${SUITESPARSE_VERSION}.tar.gz" "gpl-sources/SuiteSparse-${SUITESPARSE_VERSION}.tar.gz" |
| 168 | + tar cf gpl-sources.tar -C gpl-sources . |
| 169 | +
|
| 170 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 171 | + with: |
| 172 | + name: cvxopt-${{ env.CVXOPT_VERSION }}-gpl-sources |
| 173 | + path: gpl-sources.tar |
| 174 | + if-no-files-found: error |
| 175 | + |
| 176 | + publish: |
| 177 | + name: Publish cvxopt ${{ matrix.version }} |
| 178 | + needs: [setup, build_wheels, gpl_sources] |
| 179 | + if: needs.setup.outputs.versions != '[]' |
| 180 | + strategy: |
| 181 | + fail-fast: false |
| 182 | + matrix: |
| 183 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 184 | + permissions: |
| 185 | + contents: write |
| 186 | + pull-requests: write |
| 187 | + uses: $/.github/workflows/_publish-wheel.yml |
| 188 | + secrets: |
| 189 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 190 | + with: |
| 191 | + artifact-pattern: cvxopt-${{ matrix.version }}-*-manylinux_riscv64 |
| 192 | + gpl-sources-artifact: cvxopt-${{ matrix.version }}-gpl-sources |
| 193 | + gpl-sources-description: gcc, fftw, suitesparse |
0 commit comments