Skip to content

docs: Update projects #34

docs: Update projects

docs: Update projects #34

# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `build_wheels` job of
# https://github.com/SparseDifferentiation/SparseDiffPy/blob/v0.3.0/.github/workflows/build-and-publish.yml
name: Build sparsediffpy wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/sparsediffpy.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-sparsediffpy.yml'
- 'docs/packages/sparsediffpy.yaml'
- 'patches/sparsediffpy/**'
push:
branches: [main]
paths:
- '.github/workflows/build-sparsediffpy.yml'
- 'docs/packages/sparsediffpy.yaml'
- 'patches/sparsediffpy/**'
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
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: sparsediffpy
version: ${{ inputs.version }}
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build sparsediffpy ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
# Matches upstream's own build-and-publish.yml matrix (minus cp311, below
# this repo's numpy>=2.5.0 floor); upstream builds no free-threaded wheel.
python: ["cp312", "cp313", "cp314"]
env:
SPARSEDIFFPY_VERSION: ${{ matrix.version }}
steps:
- name: Checkout sparsediffpy v${{ env.SPARSEDIFFPY_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: SparseDifferentiation/SparseDiffPy
ref: v${{ env.SPARSEDIFFPY_VERSION }}
submodules: recursive
persist-credentials: false
- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false
- name: Patch sparsediffpy source
run: git apply python-wheels/patches/sparsediffpy/${{ env.SPARSEDIFFPY_VERSION }}/*.patch
- name: Build wheels
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 }}
# CMakeLists.txt find_package(BLAS)s unconditionally on Linux; stage its
# licence beside ours since auditwheel will vendor libopenblas.so.0 in.
CIBW_BEFORE_ALL_LINUX: >-
dnf -y install openblas-devel &&
cp /usr/share/licenses/openblas/LICENSE {project}/LICENSE.openblas
# numpy has riscv64 wheels only on our registry.
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
# Upstream ships no test suite for this package; build one C node,
# the smallest real exercise of the extension.
CIBW_TEST_COMMAND: >-
python -c "from sparsediffpy import _sparsediffengine as e; assert e.make_variable(2, 1, 0, 1)"
- name: Check the wheel ships the extension and both licences
run: |
python3 - wheelhouse/*.whl <<'EOF'
import sys, zipfile
for whl in sys.argv[1:]:
names = zipfile.ZipFile(whl).namelist()
assert any(n.startswith("sparsediffpy/_sparsediffengine.") and n.endswith(".so")
for n in names), whl
licences = {n.rsplit("/", 1)[1]
for n in names if ".dist-info/licenses/" in n} - {""}
assert licences == {"LICENSE", "LICENSE.openblas"}, (whl, licences)
print(whl, "ok")
EOF
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sparsediffpy-${{ env.SPARSEDIFFPY_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) }}
# OpenBLAS is compiled with gfortran, so auditwheel vendors the image's
# libgfortran into sparsediffpy.libs/.
name: Collect GPL sources (gcc) for sparsediffpy ${{ matrix.version }}
runs-on: ubuntu-24.04-riscv
env:
SPARSEDIFFPY_VERSION: ${{ matrix.version }}
steps:
- name: Collect gcc source RPM from manylinux_riscv64
uses: riseproject-dev/python-wheels/actions/collect-gpl-sources@main
with:
image: ${{ env.MANYLINUX_RISCV64_IMAGE }}
packages: gcc
output: gpl-sources.tar
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sparsediffpy-${{ env.SPARSEDIFFPY_VERSION }}-gpl-sources
path: gpl-sources.tar
if-no-files-found: error
publish:
name: Publish sparsediffpy ${{ 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: sparsediffpy-${{ matrix.version }}-*-manylinux_riscv64
gpl-sources-artifact: sparsediffpy-${{ matrix.version }}-gpl-sources
gpl-sources-description: gcc