diff --git a/.github/workflows/build-vmprof.yml b/.github/workflows/build-vmprof.yml new file mode 100644 index 000000000000..fa588ed3d45c --- /dev/null +++ b/.github/workflows/build-vmprof.yml @@ -0,0 +1,126 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# Based on: https://github.com/vmprof/vmprof-python/blob/release-0.6.0/.github/workflows/cibuildwheel.yml +name: Build vmprof wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/vmprof.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-vmprof.yml' + - 'docs/packages/vmprof.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-vmprof.yml' + - 'docs/packages/vmprof.yaml' + +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 + LIBUNWIND_VERSION: '1.8.3' + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: vmprof + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build vmprof ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + # Upstream's own CIBW_SKIP drops cp3*t-*: vmprof does not support + # free-threaded CPython. + python: ["cp312", "cp313", "cp314"] + + env: + VMPROF_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout vmprof ${{ env.VMPROF_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: vmprof/vmprof-python + ref: ${{ env.VMPROF_VERSION }} + persist-credentials: false + + - 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 }} + # Upstream's before-build is a plain `dnf install -y libunwind-devel`, which + # works on their manylinux_2_28 (AlmaLinux 8) images. RHEL 10 (what + # manylinux_2_39 riscv64 is built on) dropped libunwind to EPEL, and manylinux + # enables no EPEL on riscv64, so the package simply doesn't exist here + # (CLAUDE.md gotcha 140). Build it from source instead: 1.8.3 has riscv64 + # support since 1.7.0 and `--libdir=/usr/lib64` is load-bearing since + # autotools otherwise installs to /usr/lib, off the riscv64 linker/pkg-config + # path. + CIBW_BEFORE_BUILD_LINUX: >- + cd /tmp && + curl -fsSLO https://github.com/libunwind/libunwind/releases/download/v${{ env.LIBUNWIND_VERSION }}/libunwind-${{ env.LIBUNWIND_VERSION }}.tar.gz && + tar xf libunwind-${{ env.LIBUNWIND_VERSION }}.tar.gz && + cd libunwind-${{ env.LIBUNWIND_VERSION }} && + ./configure --prefix=/usr --libdir=/usr/lib64 --disable-documentation + --disable-tests --disable-minidebuginfo --disable-zlibdebuginfo && + make -j"$(nproc)" install + CIBW_TEST_GROUPS: test + CIBW_TEST_COMMAND: cd {package} && pytest vmprof jitlog -vv + + - name: Check the wheel ships the extension and licence + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + for whl in sys.argv[1:]: + names = zipfile.ZipFile(whl).namelist() + assert any(n.startswith("vmprof/") and n.endswith(".so") for n in names), whl + assert any(n.endswith(".dist-info/licenses/LICENSE") for n in names), whl + print(whl, "ok") + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: vmprof-${{ env.VMPROF_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish vmprof ${{ matrix.version }} + needs: [setup, build_wheels] + 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: vmprof-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/vmprof.yaml b/docs/packages/vmprof.yaml new file mode 100644 index 000000000000..a3cb560c423a --- /dev/null +++ b/docs/packages/vmprof.yaml @@ -0,0 +1,5 @@ +package-name: vmprof +source-code: https://github.com/vmprof/vmprof-python +license: MIT +versions: +- version: 0.6.0