Skip to content
Merged
Show file tree
Hide file tree
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
120 changes: 120 additions & 0 deletions .github/workflows/build-clingo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on: https://github.com/potassco/clingo/blob/v5.8.2/.github/workflows/cibuildwheel.yml
name: Build clingo wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/clingo.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-clingo.yml'
- 'docs/packages/clingo.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-clingo.yml'
- 'docs/packages/clingo.yaml'

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

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

env:
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: clingo
version: ${{ inputs.version }}

build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build clingo ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
# Mirrors upstream's own CIBW_BUILD (a per-interpreter .so, not abi3);
# musllinux and the i686/aarch64/ppc64le/Windows/macOS legs upstream
# also builds are dropped, same as every other Linux-only port here.
python: ["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]

env:
CLINGO_VERSION: ${{ matrix.version }}

steps:
- name: Checkout clingo v${{ env.CLINGO_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: potassco/clingo
ref: v${{ env.CLINGO_VERSION }}
submodules: recursive
persist-credentials: false

- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: wheelhouse/
env:
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# cffi, a runtime dependency of the built extension, has no riscv64
# wheel on public PyPI.
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
# The wheel does not ship libpyclingo/clingo/tests (CMake installs
# only *.py/*.typed); stage it and copy it next to the installed
# package so its relative imports resolve, then run it exactly as
# CMake's own `test_pyclingo` target does (gotcha 513).
CIBW_TEST_SOURCES: libpyclingo/clingo/tests
CIBW_TEST_COMMAND: >-
python -c "import clingo, os, shutil; d = os.path.dirname(clingo.__file__); shutil.copytree('libpyclingo/clingo/tests', os.path.join(d, 'tests'))" &&
python -m unittest discover -s "$(python -c 'import clingo, os; print(os.path.dirname(clingo.__file__))')/tests" -t "$(python -c 'import clingo, os; print(os.path.dirname(os.path.dirname(clingo.__file__)))')" -v

- name: Check the wheel ships the compiled extension
run: |
python3 - wheelhouse/*.whl <<'EOF'
import sys, zipfile

for whl in sys.argv[1:]:
names = zipfile.ZipFile(whl).namelist()
assert any(n.startswith("clingo/_clingo.") and n.endswith(".so") for n in names), whl
print(whl, "ok")
EOF

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

publish:
name: Publish clingo ${{ matrix.version }}
needs: [setup, build_wheels]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
artifact-pattern: clingo-${{ matrix.version }}-*-manylinux_riscv64
5 changes: 5 additions & 0 deletions docs/packages/clingo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package-name: clingo
source-code: https://github.com/potassco/clingo
license: MIT
versions:
- version: 5.8.2
Loading