Skip to content

Commit e18dc47

Browse files
authored
pymunk: add build-pymunk.yml for riscv64 wheels (#1751)
* **Package**: `pymunk` * **Version**: `7.3.0` * **Source**: https://github.com/viblo/pymunk.git * **Docs**: https://www.pymunk.org Compiles the vendored Munk2D (a Chipmunk2D fork maintained by pymunk's author) submodule into a cffi extension. Upstream publishes no riscv64 wheel. Mirrors [upstream's `wheels.yml`](https://github.com/viblo/pymunk/blob/7.3.0/.github/workflows/wheels.yml). **Differs from upstream** - Matrix trimmed to cp312/cp313/cp314/cp314t (our floor) - upstream also builds cp39-cp311 and pp311. - `CIBW_ENVIRONMENT` adds pypi.riseproject.dev - cffi has no riscv64 wheel on PyPI. **Testing** - same as upstream **License**: OK Built on cp312; pending CI results.
1 parent 980308c commit e18dc47

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

‎.github/workflows/build-pymunk.yml‎

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+
# Based on upstream's own wheel builder:
5+
# https://github.com/viblo/pymunk/blob/7.3.0/.github/workflows/wheels.yml
6+
name: Build pymunk wheels (riscv64)
7+
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: 'pymunk version to build (git tag, e.g. 7.3.0)'
13+
required: true
14+
default: '7.3.0'
15+
pull_request:
16+
paths:
17+
- '.github/workflows/build-pymunk.yml'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ inputs.version || '7.3.0' }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: read # to fetch code (actions/checkout)
25+
26+
env:
27+
# `inputs.version` is empty on pull_request events; default to 7.3.0 there.
28+
PYMUNK_VERSION: ${{ inputs.version || '7.3.0' }}
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_sdist:
36+
needs: [setup]
37+
name: Build pymunk ${{ inputs.version || '7.3.0' }} sdist
38+
runs-on: ubuntu-latest
39+
outputs:
40+
sdist_name: ${{ steps.sdist.outputs.sdist_name }}
41+
package_version: ${{ steps.sdist.outputs.package_version }}
42+
steps:
43+
- name: Checkout pymunk ${{ env.PYMUNK_VERSION }}
44+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
45+
with:
46+
repository: viblo/pymunk
47+
ref: ${{ env.PYMUNK_VERSION }}
48+
# Munk2D (vendored Chipmunk2D) is a submodule; MANIFEST.in's
49+
# recursive-include only bundles it into the sdist if present.
50+
submodules: true
51+
persist-credentials: false
52+
53+
- name: Install Python
54+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
55+
with:
56+
python-version: '3.12'
57+
activate-environment: true
58+
enable-cache: false
59+
60+
- name: Build sdist
61+
id: sdist
62+
run: |
63+
uv pip install build
64+
python -m build --sdist
65+
sdists=(dist/*.tar.gz)
66+
sdist_name="$(basename "${sdists[0]}")"
67+
echo "sdist_name=${sdist_name}" >> "$GITHUB_OUTPUT"
68+
echo "package_version=$(echo "${sdist_name}" | sed -En 's/pymunk-(.+)\.tar\.gz/\1/p')" >> "$GITHUB_OUTPUT"
69+
70+
- name: Upload sdist artifact
71+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
72+
with:
73+
name: pymunk-${{ env.PYMUNK_VERSION }}-sdist
74+
path: dist/*.tar.gz
75+
if-no-files-found: error
76+
77+
build_wheels:
78+
needs: [setup, build_sdist]
79+
name: Build pymunk ${{ inputs.version || '7.3.0' }} ${{ matrix.python }}-manylinux_riscv64
80+
runs-on: ubuntu-24.04-riscv
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
python: ["cp312", "cp313", "cp314", "cp314t"]
85+
86+
steps:
87+
- name: Download sdist
88+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
89+
with:
90+
name: pymunk-${{ env.PYMUNK_VERSION }}-sdist
91+
path: dist/
92+
93+
- uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
94+
with:
95+
package-dir: dist/${{ needs.build_sdist.outputs.sdist_name }}
96+
env:
97+
CIBW_ARCHS: riscv64
98+
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
99+
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
100+
# cffi, needed to build and to import the extension, has no riscv64 wheel on PyPI.
101+
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
102+
103+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
104+
with:
105+
name: pymunk-${{ needs.build_sdist.outputs.package_version }}-${{ matrix.python }}-manylinux_riscv64
106+
path: ./wheelhouse/*.whl
107+
if-no-files-found: error
108+
109+
publish:
110+
name: Publish pymunk ${{ inputs.version || '7.3.0' }}
111+
needs: [setup, build_sdist, build_wheels]
112+
permissions:
113+
contents: write
114+
pull-requests: write
115+
uses: $/.github/workflows/_publish-wheel.yml
116+
with:
117+
artifact-pattern: pymunk-${{ needs.build_sdist.outputs.package_version }}-*-manylinux_riscv64

0 commit comments

Comments
 (0)