diff --git a/.github/workflows/build-bitarray-hardbyte.yml b/.github/workflows/build-bitarray-hardbyte.yml new file mode 100644 index 000000000..97241ce49 --- /dev/null +++ b/.github/workflows/build-bitarray-hardbyte.yml @@ -0,0 +1,112 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# bitarray-hardbyte is a one-off PyPI redistribution of ilanschnell/bitarray +# under a different project name (see the docs entry / PR description); this +# workflow is based on the `build_wheels` job of +# https://github.com/ilanschnell/bitarray/blob/50b62ede70b9ef5f553e1463bb912d2bc45a174d/.github/workflows/build_wheels.yml +name: Build bitarray-hardbyte wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'bitarray-hardbyte version to build (e.g. 2.3.8)' + required: true + default: '2.3.8' + pull_request: + paths: + - '.github/workflows/build-bitarray-hardbyte.yml' + - 'patches/bitarray-hardbyte/**' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '2.3.8' }}-${{ 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 2.3.8 there. + BITARRAY_HARDBYTE_VERSION: ${{ inputs.version || '2.3.8' }} + # bitarray-hardbyte 2.3.8 has no matching git tag in ilanschnell/bitarray + # (gotcha 103): this is "next release 2.3.8" (BITARRAY_VERSION bumped, never + # tagged upstream), advanced to the last commit before "next release 2.4.0" + # finalized. Every file is byte-identical to the PyPI sdist except setup.py's + # `name`, which patches/bitarray-hardbyte/2.3.8 restores. Update it alongside + # BITARRAY_HARDBYTE_VERSION. + BITARRAY_HARDBYTE_REF: 50b62ede70b9ef5f553e1463bb912d2bc45a174d + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build bitarray-hardbyte ${{ inputs.version || '2.3.8' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + python: + - "cp312" + - "cp313" + - "cp314" + - "cp314t" + + steps: + - name: Checkout bitarray-hardbyte ${{ env.BITARRAY_HARDBYTE_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ilanschnell/bitarray + ref: ${{ env.BITARRAY_HARDBYTE_REF }} + persist-credentials: false + + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + - name: Patch bitarray-hardbyte source + run: git apply python-wheels/patches/bitarray-hardbyte/${{ env.BITARRAY_HARDBYTE_VERSION }}/*.patch + + - 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 }} + CIBW_TEST_COMMAND: python -c "import bitarray; assert bitarray.test().wasSuccessful()" + + - name: Check the C extensions and LICENSE made it into the wheel + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + for whl in sys.argv[1:]: + names = zipfile.ZipFile(whl).namelist() + for mod in ("_bitarray", "_util"): + assert any(mod in n and n.endswith(".so") for n in names), (whl, mod) + assert any(n.endswith(".dist-info/licenses/LICENSE") + or n.endswith(".dist-info/LICENSE") for n in names), names + print(whl, "ok") + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: bitarray-hardbyte-${{ env.BITARRAY_HARDBYTE_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish bitarray-hardbyte ${{ inputs.version || '2.3.8' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: bitarray-hardbyte-${{ inputs.version || '2.3.8' }}-*-manylinux_riscv64 diff --git a/patches/bitarray-hardbyte/2.3.8/0001-setup-rename-distribution-to-bitarray-hardbyte.patch b/patches/bitarray-hardbyte/2.3.8/0001-setup-rename-distribution-to-bitarray-hardbyte.patch new file mode 100644 index 000000000..6350f5b12 --- /dev/null +++ b/patches/bitarray-hardbyte/2.3.8/0001-setup-rename-distribution-to-bitarray-hardbyte.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Mon, 7 Sep 2026 13:32:21 +0000 +Subject: [PATCH] setup: rename distribution to bitarray-hardbyte + +Upstream-Status: Inappropriate [downstream redistribution naming, irrelevant to ilanschnell/bitarray] + +The PyPI project we are building wheels for is `bitarray-hardbyte`, a +one-off redistribution of ilanschnell/bitarray published under a +different project name (see the port's docs entry / PR description for +how BITARRAY_HARDBYTE_REF was chosen: it is the commit where +BITARRAY_VERSION was "2.3.8" and the cibuildwheel workflow that hardbyte +contributed upstream in PR ilanschnell/bitarray#170 had just landed). +That release's actual sdist on PyPI carries this same one-line rename in +setup.py -- verified by diffing files.pythonhosted.org's +bitarray-hardbyte-2.3.8.tar.gz against this commit, which is otherwise +byte-identical. Reapply it so our wheel's distribution name matches the +package we publish. + +Signed-off-by: Ludovic Henry +--- + setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index a477971..040e183 100644 +--- a/setup.py ++++ b/setup.py +@@ -18,7 +18,7 @@ kwds['version'] = pat.search(data).group(1) + + + setup( +- name = "bitarray", ++ name = "bitarray-hardbyte", + author = "Ilan Schnell", + author_email = "ilanschnell@gmail.com", + url = "https://github.com/ilanschnell/bitarray", +-- +2.50.1 diff --git a/patches/bitarray-hardbyte/2.3.8/0002-test_bitarray-replace-removed-unittest.makeSuite.patch b/patches/bitarray-hardbyte/2.3.8/0002-test_bitarray-replace-removed-unittest.makeSuite.patch new file mode 100644 index 000000000..66ef2f70b --- /dev/null +++ b/patches/bitarray-hardbyte/2.3.8/0002-test_bitarray-replace-removed-unittest.makeSuite.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Mon, 7 Sep 2026 14:00:00 +0000 +Subject: [PATCH] test_bitarray: replace removed unittest.makeSuite() + +Upstream-Status: Backport [https://github.com/ilanschnell/bitarray/commit/d345e9a3b5cf6a8f876567b36551e48767a89a0e] + +unittest.makeSuite() was deprecated in Python 3.11 and removed in 3.13 +(bpo-45162 / gh-92220). bitarray-hardbyte is pinned to a 2022 commit +whose test_bitarray.py still calls it, so `bitarray.test()` raises +AttributeError under cp313/cp314/cp314t: "module 'unittest' has no +attribute 'makeSuite'". This reproduces on any architecture running +those interpreters, not just riscv64. + +Upstream fixed this the same way in d345e9a3 ("avoid deprecated +unittest.makeSuite", 2023-09-16), once bitarray/test_bitarray.py had +moved past line 4431; this backports that one-line change onto our +pinned commit rather than dropping test coverage from the workflow. + +Signed-off-by: Ludovic Henry +--- + bitarray/test_bitarray.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/bitarray/test_bitarray.py b/bitarray/test_bitarray.py +index b126b2e..014a564 100644 +--- a/bitarray/test_bitarray.py ++++ b/bitarray/test_bitarray.py +@@ -4428,7 +4428,7 @@ def run(verbosity=1, repeat=1): + suite = unittest.TestSuite() + for cls in tests: + for _ in range(repeat): +- suite.addTest(unittest.makeSuite(cls)) ++ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(cls)) + + runner = unittest.TextTestRunner(verbosity=verbosity) + return runner.run(suite) +-- +2.50.1