Skip to content
Merged
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
116 changes: 116 additions & 0 deletions .github/workflows/build-pymupdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on upstream's own wheel build driver:
# https://github.com/pymupdf/PyMuPDF/blob/1.28.2/scripts/gh_release.py
name: Build pymupdf wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'pymupdf version to build (git tag, e.g. 1.28.2)'
required: true
default: '1.28.2'
pull_request:
paths:
- '.github/workflows/build-pymupdf.yml'

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

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

env:
# `inputs.version` is empty on pull_request events; default to 1.28.2 there.
PYMUPDF_VERSION: ${{ inputs.version || '1.28.2' }}
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

jobs:
build_wheels:
name: Build pymupdf ${{ inputs.version || '1.28.2' }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
# setup.py downloads and builds the whole of MuPDF (incl. tesseract/leptonica),
# generates its C++ bindings with libclang and wraps them with SWIG.
timeout-minutes: 1440
strategy:
fail-fast: false
matrix:
include:
# Upstream publishes cp310-abi3 + cp314t, i.e. two builds (gotcha 11).
# cp312 is our floor, so the abi3 wheel is built there.
- python: cp312
py_limited_api: '1'
# pipcl asserts Py_LIMITED_API and Py_GIL_DISABLED are mutually
# exclusive, so the free-threaded build must opt out of the stable ABI.
- python: cp314t
py_limited_api: '0'

steps:
- name: Checkout pymupdf ${{ env.PYMUPDF_VERSION }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: pymupdf/PyMuPDF
ref: ${{ env.PYMUPDF_VERSION }}
persist-credentials: false

- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: wheelhouse/
only: ${{ matrix.python }}-manylinux_riscv64
env:
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# mupdf's C++ bindings are generated by parsing its headers with
# libclang; the `libclang` PyPI wheel setup.py asks for by default has
# no riscv64 build, so use the image's own libclang.so instead (dnf
# `clang-devel` supplies the unversioned symlink clang.cindex dlopens).
CIBW_BEFORE_ALL_LINUX: dnf install -y clang-devel
CIBW_ENVIRONMENT: >-
PYMUPDF_SETUP_PY_LIMITED_API=${{ matrix.py_limited_api }}
PYMUPDF_SETUP_LIBCLANG=clang
PYMUPDF_SETUP_SWIG=swig
XCFLAGS=-D__LITTLE_ENDIAN__
XCXXFLAGS=-D__LITTLE_ENDIAN__
PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
# Upstream's test deps (scripts/gh_release.py:test_packages), minus the
# linters - see the ignores below.
CIBW_TEST_REQUIRES: pytest fontTools pymupdf-fonts pillow psutil
# Upstream harness, restricted to `-i r` (the default implementation):
# `rR` reruns the whole suite a second time with PYMUPDF_USE_EXTRA=0,
# which doubles an already long run on this runner.
# test_flake8/test_pylint/test_codespell lint the source tree rather
# than exercise the wheel, and track whatever linter version pip
# resolves today, so they are arch-independent noise here.
CIBW_TEST_COMMAND: >-
python {package}/tests/run_compound.py -i r
pytest {package}/tests
--ignore {package}/tests/test_flake8.py
--ignore {package}/tests/test_pylint.py
--ignore {package}/tests/test_codespell.py

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

publish:
name: Publish pymupdf ${{ inputs.version || '1.28.2' }} to GitLab
needs: [build_wheels]
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: pymupdf-${{ env.PYMUPDF_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 }}
Loading