Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/build-pillow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
name: Build pillow wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'pillow version to build (git tag without leading v, e.g. 12.3.0)'
required: true
default: '12.3.0'
pull_request:
paths:
- '.github/workflows/build-pillow.yml'
- '.github/workflows/test-pillow.yml'
- 'patches/pillow/**'

concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '12.3.0' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
PILLOW_VERSION: ${{ inputs.version || '12.3.0' }}
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:
build_wheels:
name: Build pillow ${{ inputs.version || '12.3.0' }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
strategy:
fail-fast: false
matrix:
python: ["cp312", "cp313", "cp314", "cp314t"]

steps:
- name: Checkout pillow v${{ env.PILLOW_VERSION }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: python-pillow/Pillow
ref: ${{ env.PILLOW_VERSION }}
submodules: true
persist-credentials: false

- name: Checkout python-wheels
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: python-wheels
persist-credentials: false

# Works around a GCC LTO bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110812)
# hit when building libavif as a Pillow wheel dependency on riscv64.
- name: Patch pillow source
run: |
git apply python-wheels/patches/pillow/${{ env.PILLOW_VERSION }}/00*.patch

- name: Install Python
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: '3.12'
activate-environment: true
enable-cache: false

- name: Build wheels
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
env:
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# libjpeg-turbo doesn't provide riscv64 SIMD before v3.2, and the
# version vendored by Pillow's wheel build is older than that; also
# disable arch-specific AOM optimization, see
# https://aomedia.issues.chromium.org/issues/492439207. Passed as
# cmake flags (picked up by the libavif build) rather than patching
# Pillow sources, matching the fix proven previously in
# wheel_builder/wheel_builder/Pillow/gitlab-ci.yml.
HOST_CMAKE_FLAGS: "-DWITH_SIMD=0 -DAOM_TARGET_CPU=generic"
CIBW_ENVIRONMENT_PASS_LINUX: HOST_CMAKE_FLAGS

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pillow-${{ env.PILLOW_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: ./wheelhouse/*.whl
if-no-files-found: error

publish:
name: Publish pillow ${{ inputs.version || '12.3.0' }} to GitLab
needs: [build_wheels]
# Only publish when the workflow was triggered from main with a specific
# version. Manual trigger is the only entry point, so checking the ref is
# enough to gate uploads.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Publish wheels and open docs PR
uses: riseproject-dev/python-wheels/actions/publish-wheels@main
with:
artifact-pattern: pillow-${{ env.PILLOW_VERSION }}-*-manylinux_riscv64
gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }}
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
gh-token: ${{ secrets.GITHUB_TOKEN }}
82 changes: 82 additions & 0 deletions .github/workflows/test-pillow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: Test pillow (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'pillow version to test (git tag without leading v, e.g. 12.3.0)'
required: true
default: '12.3.0'
pull_request:
paths:
- '.github/workflows/test-pillow.yml'

concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '12.3.0' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
FORCE_COLOR: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1
PILLOW_VERSION: ${{ inputs.version || '12.3.0' }}

jobs:
test:
permissions:
contents: read
name: "Test pillow ${{ inputs.version || '12.3.0' }} — Python ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04-riscv
python-version: '3.12'

steps:
- name: Checkout pillow v${{ env.PILLOW_VERSION }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: python-pillow/Pillow
ref: ${{ env.PILLOW_VERSION }}
submodules: true
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: false

- name: Install Linux dependencies
run: |
.ci/install.sh
env:
GHA_PYTHON_VERSION: ${{ matrix.python-version }}

- name: Build
run: |
.ci/build.sh

- name: Test
run: |
xvfb-run -s '-screen 0 1024x768x24' sway&
export WAYLAND_DISPLAY=wayland-1
.ci/test.sh

- name: Prepare to upload errors
if: failure()
run: |
mkdir -p Tests/errors

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure()
with:
name: "pillow-${{ env.PILLOW_VERSION }}-py${{ matrix.python-version }}-${{ matrix.os }}-errors"
path: Tests/errors
33 changes: 33 additions & 0 deletions patches/pillow/12.3.0/0001-disable-lto-when-building-libavif.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From e16f5961f165ce43fe4bcdb7eb167d2714f2b116 Mon Sep 17 00:00:00 2001
From: Mark Ryan <markdryan@rivosinc.com>
Date: Wed, 23 Jul 2025 16:50:28 +0000
Subject: [PATCH] disable lto when building libavif

This is due to a gcc bug

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110812

Upstream-Status: Inappropriate [It's a GCC bug]

Signed-off-by: Mark Ryan <markdryan@rivosinc.com>

Refresh the patch to apply on 12.3.0.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
.github/workflows/wheels-dependencies.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh
index 76d4ce22f..8b1c2f3a1 100755
--- a/.github/workflows/wheels-dependencies.sh
+++ b/.github/workflows/wheels-dependencies.sh
@@ -181,7 +181,7 @@ function build_libavif {
fi

local build_shared=ON
- local lto=ON
+ local lto=OFF

local libavif_cmake_flags

Loading