Skip to content

Commit 02ab319

Browse files
committed
Experimental: draft cibuildwheel workflow
1 parent c64a883 commit 02ab319

File tree

3 files changed

+113
-2
lines changed

3 files changed

+113
-2
lines changed

.github/workflows/cibuildwheel.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# SPDX-FileCopyrightText: 2025 wojiushixiaobai <[email protected]>
2+
# SPDX-FileCopyrightText: 2025 geisserml <[email protected]>
3+
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
4+
5+
name: Build with cibuildwheel
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
cibw_py_ver:
10+
default: 'cp312'
11+
type: string
12+
existing:
13+
default: true
14+
type: boolean
15+
ibm:
16+
default: true
17+
type: boolean
18+
emulated:
19+
default: true
20+
type: boolean
21+
22+
permissions: {}
23+
24+
jobs:
25+
26+
build_wheels:
27+
name: Build wheel for ${{ matrix.arch }} ${{ matrix.image }} (runs on ${{ matrix.os }})
28+
runs-on: ${{ matrix.os }}
29+
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
# GitHub doesn't seem to have a proper way to make conditional matrix entries,
34+
# so we have to use an `enabled` property and check it on each step (nasty).
35+
include:
36+
- os: ubuntu-24.04
37+
arch: x86_64
38+
image: manylinux
39+
enabled: ${{ inputs.existing }}
40+
needs_emulator: false
41+
- os: ubuntu-24.04-arm
42+
arch: aarch64
43+
image: manylinux
44+
enabled: ${{ inputs.existing }}
45+
needs_emulator: false
46+
# ppc64le and s390x will become native as soon as we get access to IBM's self-hosted runners
47+
- os: ubuntu-24.04
48+
arch: ppc64le
49+
image: manylinux
50+
enabled: ${{ inputs.ibm }}
51+
needs_emulator: true # false
52+
- os: ubuntu-24.04
53+
arch: s390x
54+
image: manylinux
55+
enabled: ${{ inputs.ibm }}
56+
needs_emulator: true # false
57+
- os: ubuntu-24.04
58+
arch: loongarch64
59+
image: manylinux
60+
enabled: ${{ inputs.emulated }}
61+
needs_emulator: true
62+
- os: ubuntu-24.04
63+
arch: riscv64
64+
image: manylinux
65+
enabled: ${{ inputs.emulated }}
66+
needs_emulator: true
67+
68+
steps:
69+
70+
- name: Check out the repo
71+
if: ${{ matrix.enabled }}
72+
uses: actions/checkout@v4
73+
with:
74+
fetch-depth: 0
75+
76+
- name: Set up QEMU
77+
if: ${{ matrix.enabled && matrix.needs_emulator }}
78+
uses: docker/setup-qemu-action@v3
79+
80+
- name: Build wheels
81+
if: ${{ matrix.enabled }}
82+
# LoongArch is not supported in mainline cibuildwheel yet, so use a patched fork for that
83+
uses: ${{ matrix.arch == 'loongarch64' && 'loong64/[email protected]' || 'pypa/[email protected]' }}
84+
env:
85+
CIBW_ARCHS: ${{ matrix.arch }}
86+
# Will be tagged as not python specific by our setup.py. inputs.cibw_py_ver only controls the version used at build time. Could also use `*`, then cibuildwheel would build with the oldest supported version, and walk through the others but skip because a compatible wheel is around already.
87+
CIBW_BUILD: "${{ inputs.cibw_py_ver }}-${{ matrix.image }}_${{ matrix.arch }}"
88+
CIBW_BEFORE_ALL_LINUX: |
89+
dnf -y install gn ninja-build freetype-devel glib2-devel lcms2-devel libjpeg-devel libpng-devel libtiff-devel openjpeg2-devel zlib-devel && \
90+
# these symlinks are required on aarch64 and loongarch64
91+
ln -s /opt/rh/gcc-toolset-14/root/bin/gcc /opt/rh/gcc-toolset-14/root/bin/${{ matrix.arch }}-linux-gnu-gcc && \
92+
ln -s /opt/rh/gcc-toolset-14/root/bin/g++ /opt/rh/gcc-toolset-14/root/bin/${{ matrix.arch }}-linux-gnu-g++ && \
93+
ln -s /opt/rh/gcc-toolset-14/root/bin/readelf /opt/rh/gcc-toolset-14/root/bin/${{ matrix.arch }}-linux-gnu-readelf && \
94+
ln -s /opt/rh/gcc-toolset-14/root/bin/nm /opt/rh/gcc-toolset-14/root/bin/${{ matrix.arch }}-linux-gnu-nm
95+
CIBW_BEFORE_BUILD: python setupsrc/pypdfium2_setup/build_native.py --vendor icu
96+
CIBW_ENVIRONMENT: PDFIUM_PLATFORM=sourcebuild
97+
# Test through cibuildwheel harness for simplicity
98+
# If we want to test on another version of the runner in the future, a new job would be needed
99+
# Also, install test dependencies from the system. Assumably, CIBW_TEST_REQUIRES would try to install them from PyPI, which won't work with our exotic platforms.
100+
CIBW_BEFORE_TEST: dnf -y install python3-pytest python3-pillow python3-numpy
101+
CIBW_TEST_COMMAND: |
102+
python -m pypdfium2 --version
103+
python -m pytest tests/
104+
with:
105+
output-dir: wheelhouse
106+
107+
- uses: actions/upload-artifact@v4
108+
if: ${{ matrix.enabled }}
109+
with:
110+
path: ./wheelhouse/*.whl
111+
name: pypdfium2-wheel-${{ matrix.arch }}

.github/workflows/conda.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
default: 'latest'
1616
type: string
1717
new_only:
18-
# only with package == "raw", ignored otherwise (actually the default should be false in that case, but I don't know if GH supports dynamic defaults depending on other inputs)
18+
# only with package == "raw", ignored otherwise (actually the default should be false in that case, but don't know if GH supports dynamic defaults depending on other inputs)
1919
default: true
2020
type: boolean
2121
test:

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ SPDX-License-Identifier = "BSD-3-Clause OR Apache-2.0"
138138
path = "pdfium_patches/cibuildwheel.patch"
139139
precedence = "aggregate"
140140
SPDX-FileCopyrightText = [
141-
"2025 wojiushixiaobai 吴小白 <[email protected]>",
141+
"2025 wojiushixiaobai <[email protected]>",
142142
"2025 geisserml <[email protected]>",
143143
]
144144
SPDX-License-Identifier = "BSD-3-Clause OR Apache-2.0"

0 commit comments

Comments
 (0)