Skip to content

Commit 4cbc5cf

Browse files
committed
pymupdfb: add build-pymupdfb.yml for riscv64 wheels
1 parent 3aeba61 commit 4cbc5cf

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# SPDX-FileCopyrightText: 2026 The RISE Project
2+
# SPDX-License-Identifier: MIT
3+
---
4+
# PyMuPDFb is pymupdf/PyMuPDF's own pipcl/setup.py build, run with
5+
# PYMUPDF_SETUP_FLAVOUR=bd instead of the default: a thin split-wheel of MuPDF's
6+
# shared libraries, built the same way scripts/gh_release.py builds it upstream.
7+
name: Build pymupdfb wheels (riscv64)
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'pymupdfb version (pymupdf/PyMuPDF git tag, e.g. 1.24.10)'
14+
required: true
15+
default: '1.24.10'
16+
pull_request:
17+
paths:
18+
- '.github/workflows/build-pymupdfb.yml'
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ inputs.version || '1.24.10' }}-${{ github.head_ref || github.run_id }}
22+
cancel-in-progress: true
23+
24+
permissions:
25+
contents: read # to fetch code (actions/checkout)
26+
27+
env:
28+
PYMUPDFB_VERSION: ${{ inputs.version || '1.24.10' }}
29+
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
30+
31+
jobs:
32+
setup:
33+
uses: $/.github/workflows/_setup.yml
34+
35+
build_wheels:
36+
needs: [setup]
37+
name: Build pymupdfb ${{ inputs.version || '1.24.10' }} py3-none-manylinux_riscv64
38+
runs-on: ubuntu-24.04-riscv
39+
# musllinux is skipped: it needs the same libclang-via-dnf workaround below,
40+
# which build-pymupdf.yml also only exercises on manylinux.
41+
timeout-minutes: 360
42+
43+
steps:
44+
- name: Checkout pymupdf/PyMuPDF ${{ env.PYMUPDFB_VERSION }}
45+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
46+
with:
47+
repository: pymupdf/PyMuPDF
48+
ref: ${{ env.PYMUPDFB_VERSION }}
49+
persist-credentials: false
50+
51+
- name: Build wheels
52+
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
53+
with:
54+
output-dir: wheelhouse/
55+
# setup.py's get_requires_for_build_wheel() always adds swig/libclang
56+
# regardless of flavour, and the resulting wheel is py3-none-*, so one
57+
# CPython selector covers it.
58+
only: cp312-manylinux_riscv64
59+
env:
60+
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
61+
# As in build-pymupdf.yml: the `libclang` PyPI wheel has no riscv64
62+
# build, so use the image's own libclang.so via the pure-Python
63+
# `clang` bindings instead (clang-devel supplies the unversioned
64+
# symlink clang.cindex dlopens).
65+
CIBW_BEFORE_ALL_LINUX: dnf install -y clang-devel
66+
CIBW_ENVIRONMENT: >-
67+
PYMUPDF_SETUP_FLAVOUR=bd
68+
PYMUPDF_SETUP_LIBCLANG=clang
69+
XCFLAGS=-D__LITTLE_ENDIAN__
70+
XCXXFLAGS=-D__LITTLE_ENDIAN__
71+
# Upstream's own gh_release.py disables repair for this flavour:
72+
# auditwheel finds nothing to add and exits non-zero. setup.py's
73+
# pipcl already tags the wheel from the image's own AUDITWHEEL_PLAT.
74+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: ''
75+
76+
- name: Check the wheel carries riscv64 MuPDF libraries
77+
run: |
78+
python3 - wheelhouse/*.whl <<'EOF'
79+
import sys, zipfile
80+
81+
EM_RISCV = 243
82+
expected_prefixes = ("pymupdf/libmupdf.so", "pymupdf/libmupdfcpp.so")
83+
84+
for whl in sys.argv[1:]:
85+
with zipfile.ZipFile(whl) as zf:
86+
names = zf.namelist()
87+
found = {p: None for p in expected_prefixes}
88+
for name in names:
89+
for p in expected_prefixes:
90+
if name.startswith(p) and found[p] is None:
91+
found[p] = name
92+
assert all(found.values()), (whl, found, names)
93+
for p, name in found.items():
94+
blob = zf.read(name)
95+
assert blob[:4] == b"\x7fELF", (name, blob[:4])
96+
machine = int.from_bytes(blob[18:20], "little")
97+
assert machine == EM_RISCV, (name, machine)
98+
print(name, "riscv64 ELF")
99+
assert any(n.endswith(".dist-info/COPYING") for n in names), names
100+
print(whl, "ok")
101+
EOF
102+
103+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
104+
with:
105+
name: pymupdfb-${{ env.PYMUPDFB_VERSION }}-py3-none-manylinux_riscv64
106+
path: wheelhouse/*.whl
107+
if-no-files-found: error
108+
109+
publish:
110+
name: Publish pymupdfb ${{ inputs.version || '1.24.10' }}
111+
needs: [setup, build_wheels]
112+
permissions:
113+
contents: write
114+
pull-requests: write
115+
uses: $/.github/workflows/_publish-wheel.yml
116+
with:
117+
artifact-pattern: pymupdfb-${{ inputs.version || '1.24.10' }}-*-manylinux_riscv64

0 commit comments

Comments
 (0)