diff --git a/.github/workflows/build-accelerator-toolbox.yml b/.github/workflows/build-accelerator-toolbox.yml new file mode 100644 index 000000000000..a30477aa72a6 --- /dev/null +++ b/.github/workflows/build-accelerator-toolbox.yml @@ -0,0 +1,133 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on: https://github.com/atcollab/at/blob/pyat-0.8.0/.github/workflows/build-python-wheels.yml +name: Build accelerator-toolbox wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/accelerator-toolbox.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-accelerator-toolbox.yml' + - 'docs/packages/accelerator-toolbox.yaml' + - 'patches/accelerator-toolbox/**' + push: + branches: [main] + paths: + - '.github/workflows/build-accelerator-toolbox.yml' + - 'docs/packages/accelerator-toolbox.yaml' + - 'patches/accelerator-toolbox/**' + +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: accelerator-toolbox + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build accelerator-toolbox ${{ 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) }} + # Per-interpreter (not abi3): the C extensions link the version-specific ABI. + # cp38/cp39 and free-threaded builds excluded: upstream's own cibuildwheel + # config skips cp3{8,9}-* and cp*t-*. cp310/cp311 dropped too: h5py (a hard + # runtime dependency) has no riscv64 wheel for either interpreter on PyPI or + # on our own registry (docs/packages/h5py.yaml starts at cp312). + python: + - "cp312" + - "cp313" + - "cp314" + + env: + ACCELERATOR_TOOLBOX_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout accelerator-toolbox pyat-${{ env.ACCELERATOR_TOOLBOX_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: atcollab/at + ref: pyat-${{ env.ACCELERATOR_TOOLBOX_VERSION }} + fetch-depth: 0 # setuptools_scm derives the version from `git describe --tags` + 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 }} + # numpy is a build-time requirement (pyproject.toml build-system.requires); + # scipy/h5py are runtime deps pulled in when cibuildwheel installs the + # wheel for the test step. Only our registry has any of these for + # riscv64; only-binary keeps a newer PyPI release from winning the + # resolution and then compiling from sdist (h5py would need libhdf5-dev). + CIBW_ENVIRONMENT: >- + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + PIP_ONLY_BINARY=numpy,scipy,h5py + CIBW_TEST_SOURCES: pyat/test + CIBW_TEST_REQUIRES: pytest + # test_long_arrays_in_m_file reads machine_data/kickmap_w150_20mm.txt, which + # pyproject.toml's package-data glob (*.m, *.mat only) never ships in any + # installed wheel -- reproduced against a local x86_64 build, unrelated to riscv64. + CIBW_TEST_COMMAND: python -m pytest pyat/test -k "not test_long_arrays_in_m_file" + + - name: Check wheel contents + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + names = zipfile.ZipFile(sys.argv[1]).namelist() + exts = {n.split("/")[-1].split(".")[0] for n in names if n.endswith(".so")} + assert "atpass" in exts, exts + assert "cconfig" in exts, exts + assert any(n.startswith("DriftPass") for n in exts), exts + licences = {n.rsplit("/", 1)[-1] for n in names if ".dist-info/licenses/" in n} - {""} + assert licences == {"LICENSE"}, licences + EOF + + - name: Store wheels + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: accelerator-toolbox-${{ env.ACCELERATOR_TOOLBOX_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish accelerator-toolbox ${{ 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: accelerator-toolbox-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/accelerator-toolbox.yaml b/docs/packages/accelerator-toolbox.yaml new file mode 100644 index 000000000000..09a37940d5c6 --- /dev/null +++ b/docs/packages/accelerator-toolbox.yaml @@ -0,0 +1,5 @@ +package-name: accelerator-toolbox +source-code: https://github.com/atcollab/at +license: Apache-2.0 +versions: +- version: 0.8.0