Skip to content

Commit b032969

Browse files
committed
Pillow: add build, test workflows for 12.3.0
Refresh the same lto libavif patch we've used for previous versions so it applies on 12.3.0 and include it in the repository. Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent 0457bf2 commit b032969

3 files changed

Lines changed: 224 additions & 0 deletions

File tree

.github/workflows/build-pillow.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
name: Build pillow wheels (riscv64)
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'pillow version to build (git tag without leading v, e.g. 12.3.0)'
9+
required: true
10+
default: '12.3.0'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/build-pillow.yml'
14+
- '.github/workflows/test-pillow.yml'
15+
- 'patches/pillow/**'
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ inputs.version || '12.3.0' }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
contents: read # to fetch code (actions/checkout)
23+
24+
env:
25+
PILLOW_VERSION: ${{ inputs.version || '12.3.0' }}
26+
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
27+
UV_INDEX_STRATEGY: unsafe-best-match
28+
UV_ONLY_BINARY: ':all:'
29+
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
30+
31+
jobs:
32+
build_wheels:
33+
name: Build pillow ${{ inputs.version || '12.3.0' }} ${{ matrix.python }}-manylinux_riscv64
34+
runs-on: ubuntu-24.04-riscv
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
python: ["cp312", "cp313", "cp314", "cp314t"]
39+
40+
steps:
41+
- name: Checkout pillow v${{ env.PILLOW_VERSION }}
42+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
43+
with:
44+
repository: python-pillow/Pillow
45+
ref: ${{ env.PILLOW_VERSION }}
46+
submodules: true
47+
persist-credentials: false
48+
49+
- name: Checkout python-wheels
50+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
51+
with:
52+
path: python-wheels
53+
persist-credentials: false
54+
55+
# Works around a GCC LTO bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110812)
56+
# hit when building libavif as a Pillow wheel dependency on riscv64.
57+
- name: Patch pillow source
58+
run: |
59+
git apply python-wheels/patches/pillow/${{ env.PILLOW_VERSION }}/00*.patch
60+
61+
- name: Install Python
62+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
63+
with:
64+
python-version: '3.12'
65+
activate-environment: true
66+
enable-cache: false
67+
68+
- name: Build wheels
69+
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
70+
env:
71+
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
72+
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
73+
# libjpeg-turbo doesn't provide riscv64 SIMD before v3.2, and the
74+
# version vendored by Pillow's wheel build is older than that; also
75+
# disable arch-specific AOM optimization, see
76+
# https://aomedia.issues.chromium.org/issues/492439207. Passed as
77+
# cmake flags (picked up by the libavif build) rather than patching
78+
# Pillow sources, matching the fix proven previously in
79+
# wheel_builder/wheel_builder/Pillow/gitlab-ci.yml.
80+
HOST_CMAKE_FLAGS: "-DWITH_SIMD=0 -DAOM_TARGET_CPU=generic"
81+
CIBW_ENVIRONMENT_PASS_LINUX: HOST_CMAKE_FLAGS
82+
83+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
84+
with:
85+
name: pillow-${{ env.PILLOW_VERSION }}-${{ matrix.python }}-manylinux_riscv64
86+
path: ./wheelhouse/*.whl
87+
if-no-files-found: error
88+
89+
publish:
90+
name: Publish pillow ${{ inputs.version || '12.3.0' }} to GitLab
91+
needs: [build_wheels]
92+
# Only publish when the workflow was triggered from main with a specific
93+
# version. Manual trigger is the only entry point, so checking the ref is
94+
# enough to gate uploads.
95+
if: github.ref == 'refs/heads/main'
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: write
99+
pull-requests: write
100+
101+
steps:
102+
- name: Publish wheels and open docs PR
103+
uses: riseproject-dev/python-wheels/actions/publish-wheels@main
104+
with:
105+
artifact-pattern: pillow-${{ env.PILLOW_VERSION }}-*-manylinux_riscv64
106+
gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }}
107+
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
108+
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
109+
gh-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-pillow.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
name: Test pillow (riscv64)
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'pillow version to test (git tag without leading v, e.g. 12.3.0)'
9+
required: true
10+
default: '12.3.0'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/test-pillow.yml'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ inputs.version || '12.3.0' }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read # to fetch code (actions/checkout)
21+
22+
env:
23+
FORCE_COLOR: 1
24+
PIP_DISABLE_PIP_VERSION_CHECK: 1
25+
PILLOW_VERSION: ${{ inputs.version || '12.3.0' }}
26+
27+
jobs:
28+
test:
29+
permissions:
30+
contents: read
31+
name: "Test pillow ${{ inputs.version || '12.3.0' }} — Python ${{ matrix.python-version }} on ${{ matrix.os }}"
32+
runs-on: ${{ matrix.os }}
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
include:
38+
- os: ubuntu-24.04-riscv
39+
python-version: '3.12'
40+
41+
steps:
42+
- name: Checkout pillow v${{ env.PILLOW_VERSION }}
43+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
44+
with:
45+
repository: python-pillow/Pillow
46+
ref: ${{ env.PILLOW_VERSION }}
47+
submodules: true
48+
persist-credentials: false
49+
50+
- name: Set up Python ${{ matrix.python-version }}
51+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
activate-environment: true
55+
enable-cache: false
56+
57+
- name: Install Linux dependencies
58+
run: |
59+
.ci/install.sh
60+
env:
61+
GHA_PYTHON_VERSION: ${{ matrix.python-version }}
62+
63+
- name: Build
64+
run: |
65+
.ci/build.sh
66+
67+
- name: Test
68+
run: |
69+
xvfb-run -s '-screen 0 1024x768x24' sway&
70+
export WAYLAND_DISPLAY=wayland-1
71+
.ci/test.sh
72+
73+
- name: Prepare to upload errors
74+
if: failure()
75+
run: |
76+
mkdir -p Tests/errors
77+
78+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
79+
if: failure()
80+
with:
81+
name: "pillow-${{ env.PILLOW_VERSION }}-py${{ matrix.python-version }}-${{ matrix.os }}-errors"
82+
path: Tests/errors
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From e16f5961f165ce43fe4bcdb7eb167d2714f2b116 Mon Sep 17 00:00:00 2001
2+
From: Mark Ryan <markdryan@rivosinc.com>
3+
Date: Wed, 23 Jul 2025 16:50:28 +0000
4+
Subject: [PATCH] disable lto when building libavif
5+
6+
This is due to a gcc bug
7+
8+
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110812
9+
10+
Upstream-Status: Inappropriate [It's a GCC bug]
11+
12+
Signed-off-by: Mark Ryan <markdryan@rivosinc.com>
13+
14+
Refresh the patch to apply on 12.3.0.
15+
16+
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
17+
---
18+
.github/workflows/wheels-dependencies.sh | 2 +-
19+
1 file changed, 1 insertion(+), 1 deletion(-)
20+
21+
diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh
22+
index 76d4ce22f..8b1c2f3a1 100755
23+
--- a/.github/workflows/wheels-dependencies.sh
24+
+++ b/.github/workflows/wheels-dependencies.sh
25+
@@ -181,7 +181,7 @@ function build_libavif {
26+
fi
27+
28+
local build_shared=ON
29+
- local lto=ON
30+
+ local lto=OFF
31+
32+
local libavif_cmake_flags
33+

0 commit comments

Comments
 (0)