Skip to content

Build cffi wheels (riscv64) #31

Build cffi wheels (riscv64)

Build cffi wheels (riscv64) #31

Workflow file for this run

---
name: Build cffi wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/cffi.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-cffi.yml'
- 'docs/packages/cffi.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-cffi.yml'
- 'docs/packages/cffi.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
env:
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
UV_INDEX_STRATEGY: unsafe-best-match
UV_ONLY_BINARY: ':all:'
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: cffi
version: ${{ inputs.version }}
python_sdist:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
runs-on: ubuntu-24.04-riscv
env:
CFFI_VERSION: ${{ matrix.version }}
steps:
- name: checkout cffi
uses: actions/checkout@v7
with:
repository: python-cffi/cffi
ref: v${{ env.CFFI_VERSION }}
submodules: true
persist-credentials: false
- name: setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: '3.12'
activate-environment: true
enable-cache: false
- name: build sdist
run: |
rm -rf dist/
uv pip install build
python -m build --sdist
- name: upload sdist artifact
uses: actions/upload-artifact@v7
with:
name: cffi-${{ env.CFFI_VERSION }}-sdist
path: dist/*.tar.gz
if-no-files-found: error
# always upload the sdist artifact- all the wheel build jobs require it
linux:
# Unlike upstream, we depend only on python_sdist, since we don't need to
# build a large matrix of targets
needs: [setup, python_sdist]
if: needs.setup.outputs.versions != '[]'
name: Build cffi ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
python: ["cp312", "cp313", "cp314", "cp314t"]
env:
CFFI_VERSION: ${{ matrix.version }}
steps:
- name: fetch sdist artifact
id: fetch_sdist
uses: actions/download-artifact@v8
with:
name: cffi-${{ env.CFFI_VERSION }}-sdist
- name: setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: '3.12'
activate-environment: true
enable-cache: false
- name: build/test wheels
id: build
env:
CFLAGS: -Dffi_call=cffistatic_ffi_call # override name for ffi_call to break hard if we linked against someone else's libffi
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
CIBW_ENVIRONMENT_PASS_LINUX: CFLAGS # ensure that the build container can see our overridden build config
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
CIBW_BEFORE_BUILD: |
set -eux && \
curl -L -O https://github.com/libffi/libffi/archive/v3.4.6.tar.gz && \
tar zxf v3.4.6.tar.gz && cd libffi-3.4.6 && \
((command -v apk && apk add libtool) || true) && \
./autogen.sh && \
./configure --without-gcc-arch --disable-docs --with-pic --enable-shared=no && \
make install && \
cd .. && \
rm -rf libffi-3.4.6
CIBW_TEST_REQUIRES: pytest setuptools meson-python ninja # 3.12+ no longer includes distutils, just always ensure setuptools is present
CIBW_TEST_COMMAND: PYTHONUNBUFFERED=1 python -m pytest {project}
run: |
set -eux
mkdir cffi
tar zxf ${{ steps.fetch_sdist.outputs.download-path }}/cffi*.tar.gz --strip-components=1 -C cffi
uv pip install --upgrade cibuildwheel
# actually build libffi + wheel (using env tweaks above)
python -m cibuildwheel --output-dir dist ./cffi
echo "artifact_name=$(ls ./dist/)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cffi-${{ env.CFFI_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: ./dist/*.whl
if-no-files-found: error
publish:
name: Publish cffi ${{ matrix.version }}
needs: [setup, linux]
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
with:
artifact-pattern: cffi-${{ matrix.version }}-*-manylinux_riscv64