From 8f17573ea9fa38fc1b8476cc577b3795605889d7 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 21 Sep 2026 22:43:52 +0000 Subject: [PATCH] clingo: Add version 5.8.2 CMake/scikit-build C++17 project (clasp/gringo/libclingo) with a CFFI-generated Python extension; no SIMD/arch-specific code, and upstream already builds aarch64/ppc64le wheels via cibuildwheel, so this mirrors that shape for riscv64. bison/re2c are not needed: CMake falls back to the pre-generated parser/lexer sources already checked into libgringo/gen. Validated locally on x86_64: build, install and the full upstream libpyclingo/clingo/tests suite (72 tests) all pass. --- .github/workflows/build-clingo.yml | 120 +++++++++++++++++++++++++++++ docs/packages/clingo.yaml | 5 ++ 2 files changed, 125 insertions(+) create mode 100644 .github/workflows/build-clingo.yml create mode 100644 docs/packages/clingo.yaml diff --git a/.github/workflows/build-clingo.yml b/.github/workflows/build-clingo.yml new file mode 100644 index 00000000000..888affd5519 --- /dev/null +++ b/.github/workflows/build-clingo.yml @@ -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 diff --git a/docs/packages/clingo.yaml b/docs/packages/clingo.yaml new file mode 100644 index 00000000000..4da80e368b7 --- /dev/null +++ b/docs/packages/clingo.yaml @@ -0,0 +1,5 @@ +package-name: clingo +source-code: https://github.com/potassco/clingo +license: MIT +versions: +- version: 5.8.2