|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `build-wheels` job of |
| 5 | +# https://github.com/abstractqqq/polars_ds_extension/blob/v0.12.1/.github/workflows/CI.yml |
| 6 | +name: Build polars-ds 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/polars-ds.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-polars-ds.yml' |
| 19 | + - 'docs/packages/polars-ds.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-polars-ds.yml' |
| 24 | + - 'docs/packages/polars-ds.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 | + CARGO_INCREMENTAL: 0 |
| 35 | + CARGO_NET_RETRY: 10 |
| 36 | + RUSTUP_MAX_RETRIES: 10 |
| 37 | + # Limit parallel rustc invocations to avoid resource exhaustion on the |
| 38 | + # riscv64 runner (build-daft.yml/build-polars-runtime.yml need the same). |
| 39 | + CARGO_BUILD_JOBS: 2 |
| 40 | + |
| 41 | +jobs: |
| 42 | + setup: |
| 43 | + uses: $/.github/workflows/_setup.yml |
| 44 | + with: |
| 45 | + package: polars-ds |
| 46 | + version: ${{ inputs.version }} |
| 47 | + |
| 48 | + build_wheels: |
| 49 | + needs: [setup] |
| 50 | + if: needs.setup.outputs.versions != '[]' |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 55 | + name: Build polars-ds ${{ matrix.version }} cp39-abi3-manylinux_riscv64 |
| 56 | + runs-on: ubuntu-24.04-riscv |
| 57 | + timeout-minutes: 1440 |
| 58 | + |
| 59 | + env: |
| 60 | + POLARS_DS_VERSION: ${{ matrix.version }} |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Checkout polars_ds_extension v${{ env.POLARS_DS_VERSION }} |
| 64 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 65 | + with: |
| 66 | + repository: abstractqqq/polars_ds_extension |
| 67 | + ref: v${{ env.POLARS_DS_VERSION }} |
| 68 | + persist-credentials: false |
| 69 | + |
| 70 | + - name: Free disk space |
| 71 | + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 |
| 72 | + |
| 73 | + # Same OOM guard build-daft.yml/build-lancedb.yml need for a comparably |
| 74 | + # sized Rust dependency tree (polars itself, plus faer/argmin). |
| 75 | + - name: Set swap space |
| 76 | + uses: pierotofy/set-swap-space@fc79b3f67fa8a838184ce84a674ca12238d2c761 # master |
| 77 | + with: |
| 78 | + swap-size-gb: 16 |
| 79 | + |
| 80 | + - name: Build wheel |
| 81 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 82 | + with: |
| 83 | + target: riscv64gc-unknown-linux-gnu |
| 84 | + # pyo3 carries `abi3-py39` unconditionally in Cargo.toml, so upstream |
| 85 | + # ships one cp39-abi3 wheel; `rust-toolchain.toml` pins a nightly |
| 86 | + # channel (faer's "nightly" feature), which maturin-action picks up |
| 87 | + # on its own, same as upstream's job does. |
| 88 | + args: --release --out dist -i python3.9 --manifest-path Cargo.toml |
| 89 | + manylinux: '2_39' |
| 90 | + env: |
| 91 | + # Matches build-polars-runtime.yml's override of py-polars' own |
| 92 | + # fat-LTO release profile: polars_ds's [profile.release] sets the |
| 93 | + # same (lto="fat", codegen-units=1), which is too heavy for these |
| 94 | + # runners stacked on top of the polars/faer/argmin dependency tree. |
| 95 | + CARGO_PROFILE_RELEASE_LTO: 'off' |
| 96 | + CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16' |
| 97 | + CARGO_PROFILE_RELEASE_OPT_LEVEL: '1' |
| 98 | + |
| 99 | + - name: Verify the wheel ships the compiled extension |
| 100 | + run: | |
| 101 | + set -euo pipefail |
| 102 | + for whl in dist/*.whl; do |
| 103 | + python3 - "$whl" <<'EOF' |
| 104 | + import sys, zipfile |
| 105 | + names = zipfile.ZipFile(sys.argv[1]).namelist() |
| 106 | + assert any(n.endswith(".so") and "_polars_ds" in n for n in names), names |
| 107 | + assert any(n.endswith(".dist-info/licenses/LICENSE.txt") for n in names), names |
| 108 | + print(sys.argv[1], "->", [n for n in names if n.endswith(".so")]) |
| 109 | + EOF |
| 110 | + done |
| 111 | +
|
| 112 | + - name: Install uv |
| 113 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 114 | + with: |
| 115 | + enable-cache: false |
| 116 | + |
| 117 | + # Upstream's own test step needs numpy/great-tables/altair extras and |
| 118 | + # pytest fixtures across the whole suite; this instead runs one of |
| 119 | + # README's own documented examples (query_roc_auc/query_log_loss) to |
| 120 | + # prove the compiled plugin registers and evaluates against polars. |
| 121 | + - name: Evaluate a documented expression against the published polars wheel |
| 122 | + env: |
| 123 | + UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/ |
| 124 | + UV_INDEX_STRATEGY: unsafe-best-match |
| 125 | + run: | |
| 126 | + set -euo pipefail |
| 127 | + venv="$RUNNER_TEMP/venv" |
| 128 | + uv venv --python 3.12 "$venv" |
| 129 | + uv pip install --python "$venv/bin/python" polars==2.0.0 dist/polars_ds-*.whl |
| 130 | + "$venv/bin/python" - <<'EOF' |
| 131 | + import polars as pl |
| 132 | + import polars_ds as pds |
| 133 | +
|
| 134 | + df = pl.DataFrame({ |
| 135 | + "segment": ["a", "a", "b", "b"], |
| 136 | + "actual": [0, 1, 0, 1], |
| 137 | + "predicted": [0.1, 0.9, 0.4, 0.6], |
| 138 | + }) |
| 139 | + out = df.lazy().group_by("segment").agg( |
| 140 | + pds.query_roc_auc("actual", "predicted").alias("roc_auc"), |
| 141 | + pds.query_log_loss("actual", "predicted").alias("log_loss"), |
| 142 | + ).sort("segment").collect() |
| 143 | + print(out) |
| 144 | + assert out["roc_auc"].to_list() == [1.0, 1.0] |
| 145 | + EOF |
| 146 | +
|
| 147 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 148 | + with: |
| 149 | + name: polars-ds-${{ env.POLARS_DS_VERSION }}-cp39-abi3-manylinux_riscv64 |
| 150 | + path: dist/*.whl |
| 151 | + if-no-files-found: error |
| 152 | + |
| 153 | + publish: |
| 154 | + name: Publish polars-ds ${{ matrix.version }} |
| 155 | + needs: [setup, build_wheels] |
| 156 | + if: needs.setup.outputs.versions != '[]' |
| 157 | + strategy: |
| 158 | + fail-fast: false |
| 159 | + matrix: |
| 160 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 161 | + permissions: |
| 162 | + contents: write |
| 163 | + pull-requests: write |
| 164 | + uses: $/.github/workflows/_publish-wheel.yml |
| 165 | + secrets: |
| 166 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 167 | + with: |
| 168 | + artifact-pattern: polars-ds-${{ matrix.version }}-cp39-abi3-manylinux_riscv64 |
0 commit comments