|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# Based on the `tests` job of |
| 5 | +# https://github.com/openslide/openslide-python/blob/v1.4.6/.github/workflows/python.yml |
| 6 | +name: Build openslide-python wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/openslide-python.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-openslide-python.yml' |
| 19 | + - 'docs/packages/openslide-python.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-openslide-python.yml' |
| 24 | + - 'docs/packages/openslide-python.yaml' |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read # to fetch code (actions/checkout) |
| 32 | + |
| 33 | +env: |
| 34 | + PYTHONUNBUFFERED: 1 |
| 35 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 36 | + |
| 37 | +jobs: |
| 38 | + setup: |
| 39 | + uses: $/.github/workflows/_setup.yml |
| 40 | + with: |
| 41 | + package: openslide-python |
| 42 | + version: ${{ inputs.version }} |
| 43 | + |
| 44 | + build_wheels: |
| 45 | + needs: [setup] |
| 46 | + if: needs.setup.outputs.versions != '[]' |
| 47 | + name: Build openslide-python ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 |
| 48 | + runs-on: ubuntu-24.04-riscv |
| 49 | + timeout-minutes: 60 |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 54 | + # setup.py tags GIL builds cp311-abi3 (built on that floor) and |
| 55 | + # free-threaded builds per interpreter. |
| 56 | + python: ["cp311", "cp314t"] |
| 57 | + |
| 58 | + env: |
| 59 | + OPENSLIDE_PYTHON_VERSION: ${{ matrix.version }} |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout openslide-python v${{ env.OPENSLIDE_PYTHON_VERSION }} |
| 63 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 64 | + with: |
| 65 | + repository: openslide/openslide-python |
| 66 | + ref: v${{ env.OPENSLIDE_PYTHON_VERSION }} |
| 67 | + persist-credentials: false |
| 68 | + |
| 69 | + - uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 70 | + env: |
| 71 | + CIBW_ARCHS: riscv64 |
| 72 | + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 |
| 73 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 74 | + |
| 75 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 76 | + with: |
| 77 | + name: openslide-python-${{ env.OPENSLIDE_PYTHON_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 78 | + path: ./wheelhouse/*.whl |
| 79 | + if-no-files-found: error |
| 80 | + |
| 81 | + # The suite needs libopenslide, which the manylinux image cannot install |
| 82 | + # (it is EPEL-only), so test on the runner against Ubuntu's, as upstream does. |
| 83 | + test_wheels: |
| 84 | + needs: [setup, build_wheels] |
| 85 | + if: needs.setup.outputs.versions != '[]' |
| 86 | + name: Test openslide-python ${{ matrix.version }} on Python ${{ matrix.python-version }} |
| 87 | + runs-on: ubuntu-24.04-riscv |
| 88 | + timeout-minutes: 60 |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 93 | + python-version: ["3.11", "3.12", "3.13", "3.14", "3.14t"] |
| 94 | + |
| 95 | + env: |
| 96 | + OPENSLIDE_PYTHON_VERSION: ${{ matrix.version }} |
| 97 | + UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/ |
| 98 | + UV_INDEX_STRATEGY: unsafe-best-match |
| 99 | + UV_ONLY_BINARY: pillow |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Checkout openslide-python v${{ env.OPENSLIDE_PYTHON_VERSION }} |
| 103 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 104 | + with: |
| 105 | + repository: openslide/openslide-python |
| 106 | + ref: v${{ env.OPENSLIDE_PYTHON_VERSION }} |
| 107 | + persist-credentials: false |
| 108 | + |
| 109 | + - name: Download wheel |
| 110 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 111 | + with: |
| 112 | + name: openslide-python-${{ env.OPENSLIDE_PYTHON_VERSION }}-${{ matrix.python-version == '3.14t' && 'cp314t' || 'cp311' }}-manylinux_riscv64 |
| 113 | + path: wheelhouse |
| 114 | + |
| 115 | + - name: Set up Python ${{ matrix.python-version }} |
| 116 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 117 | + with: |
| 118 | + python-version: ${{ matrix.python-version }} |
| 119 | + activate-environment: true |
| 120 | + enable-cache: false |
| 121 | + |
| 122 | + - name: Install OpenSlide (system) |
| 123 | + run: | |
| 124 | + sudo apt-get update -qq |
| 125 | + sudo apt-get install -y -qq libopenslide0 |
| 126 | +
|
| 127 | + - name: Install |
| 128 | + run: uv pip install jinja2 pytest wheelhouse/*.whl |
| 129 | + |
| 130 | + - name: Run tests |
| 131 | + run: pytest -v |
| 132 | + |
| 133 | + - name: Tile slide |
| 134 | + run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs |
| 135 | + |
| 136 | + publish: |
| 137 | + name: Publish openslide-python ${{ matrix.version }} |
| 138 | + needs: [setup, build_wheels, test_wheels] |
| 139 | + if: needs.setup.outputs.versions != '[]' |
| 140 | + strategy: |
| 141 | + fail-fast: false |
| 142 | + matrix: |
| 143 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 144 | + permissions: |
| 145 | + contents: write |
| 146 | + pull-requests: write |
| 147 | + uses: $/.github/workflows/_publish-wheel.yml |
| 148 | + secrets: |
| 149 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 150 | + with: |
| 151 | + artifact-pattern: openslide-python-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments