Skip to content

chore: port changes to CFFI implementation #268

chore: port changes to CFFI implementation

chore: port changes to CFFI implementation #268

Workflow file for this run

name: build
on:
push:
branches:
- "master"
- "ci-*"
tags:
- "**"
pull_request:
workflow_dispatch:
permissions: {}
env:
PY_COLORS: 1
jobs:
test_integration:
name: Test integration | Python 3.14
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.14"
- name: Test
run: python tests/test_integration.py
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Install dependencies
run: python -m pip install -U build
- name: Build sdist
run: python -m build --sdist
- name: List distributions
run: ls -lR dist
- name: Save build artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: sdist
path: dist
- name: Install sdist
run: python -m pip install dist/*.tar.gz
- name: Test
run: python -m unittest discover tests -v
define_build_wheels_matrix:
name: Define build wheels matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.define.outputs.matrix }}
full: ${{ steps.define.outputs.full }}
env:
PYTHON_VERSIONS: cp310 cp311 cp312 cp313 pp310 pp311
FULL:
${{ ( startsWith(github.ref, 'refs/tags') || startsWith(github.head_ref,
'release-') || github.event_name == 'workflow_dispatch' ) && '1' || '0' }}
steps:
- name: Define include matrix
id: define
shell: python
run: |
import json
import os
PYTHON_VERSIONS = os.environ["PYTHON_VERSIONS"].split()
FULL = os.environ["FULL"] == "1"
CASES = []
def add(name, runner, platform, archs, build, qemu=False):
CASES.append(locals())
for identifier in ("manylinux", "musllinux"):
build = " ".join(f"{py}-{identifier}_*" for py in PYTHON_VERSIONS if identifier=="manylinux" or py.startswith("cp"))
add(f"Linux regular {identifier}", "ubuntu-latest", "linux", "x86_64 i686", build)
if FULL:
for arch in ("aarch64", "ppc64le", "riscv64", "s390x"):
add(f"Linux {arch} {identifier}", "ubuntu-latest", "linux", arch, build, True)
build = " ".join(f"{py}-*" for py in PYTHON_VERSIONS)
add("Windows regular", "windows-latest", "windows", "AMD64 x86", build)
if FULL:
add("Windows arm", "windows-11-arm", "windows", "ARM64", build)
add("macOS regular", "macos-latest", "macos", "x86_64 arm64", build)
add("Android regular", "ubuntu-latest", "android", "arm64_v8a x86_64", "cp313-*")
add("iOS regular", "macos-14", "ios", "all", "cp313-*") # "macos-14" because of https://github.com/actions/runner-images/issues/12777
print("full:", FULL)
print(json.dumps(CASES, indent=2))
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
if FULL:
f.write("full=1\n")
f.write(f"matrix={json.dumps(CASES, indent=None)}\n")
build_wheels:
name: Build wheels | ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
needs:
- build_sdist
- define_build_wheels_matrix
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.define_build_wheels_matrix.outputs.matrix) }}
env:
CIBW_PLATFORM: ${{ matrix.platform }}
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_BUILD: ${{ matrix.build }}
CIBW_ENABLE: pypy pypy-eol
CIBW_TEST_COMMAND: python -m unittest discover tests -v
CIBW_TEST_SOURCES: tests
steps:
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Install dependencies
run: python -m pip install -U cibuildwheel
- name: Download sdist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sdist
path: sdist
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
if: ${{ matrix.qemu }}
- name: Build wheels
run: python -m cibuildwheel --output-dir dist sdist/*.tar.gz
shell: bash
- name: List distributions
run: ls -lR dist
shell: bash
- name: Save build artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: wheels ${{ matrix.name }}
path: dist/*.whl
test_specific_python_versions:
name: Test on Python version | ${{ matrix.version }}
runs-on: ubuntu-latest
container: docker.io/library/python:${{ matrix.version }}-slim
needs:
- build_wheels
strategy:
fail-fast: false
matrix:
include:
- version: "3.10.0"
file_pattern: "*-cp310-cp310-manylinux*x86_64*.whl"
- version: "3.11.0"
file_pattern: "*-cp311-cp311-manylinux*x86_64*.whl"
- version: "3.12.0"
file_pattern: "*-cp312-cp312-manylinux*x86_64*.whl"
- version: "3.13.0"
file_pattern: "*-cp313-cp313-manylinux*x86_64*.whl"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Restore build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: wheels Linux regular manylinux
path: dist
- name: Python version
run: python -VV
- name: Install package
run: python -m pip install dist/${{ matrix.file_pattern }}
- name: Test
run: python -m unittest discover tests -v
test_debug:
name: Test with DEBUG | ${{ matrix.python }}
runs-on: ubuntu-latest
needs:
- build_sdist
strategy:
fail-fast: false
matrix:
python:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.13t"
- "pypy-3.10"
- "pypy-3.11"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "${{ matrix.python }}"
- name: Restore build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sdist
path: dist
- name: Install package
run: CFLAGS='-UNDEBUG' python -m pip install dist/*.tar.gz
- name: Test
run: python -m unittest discover tests -v
test_system_zstd:
name:
Test system zstd | ${{ matrix.pypy && 'PyPy' || 'CPython' }} ${{ matrix.system &&
'system' || 'distributed' }}
runs-on: ubuntu-latest
needs:
- build_sdist
strategy:
fail-fast: false
matrix:
pypy: [false, true]
system: [false, true]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "${{ matrix.pypy && 'pypy3.11' || '3.13' }}"
- name: Restore build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sdist
path: dist
- name: Install package
run:
python -m pip install ${{ matrix.system &&
'--config-settings=--build-option=--system-zstd' || '' }} dist/*.tar.gz
- name: Check dynamic libraries requirements
shell: python
run: |
from backports import zstd
import inspect
import subprocess
import sys
filename = inspect.getfile(zstd.${{ matrix.pypy && '_zstd_cffi' || '_zstd' }})
ldd_out = subprocess.check_output(["ldd", filename], text=True)
print(ldd_out)
expected_zstd = ${{ matrix.system && 'True' || 'False' }}
got_zstd = "zstd" in ldd_out
sys.exit(got_zstd != expected_zstd)
- name: Test
run: python -m unittest discover tests -v
env:
BACKPORTSZSTD_SKIP_EXTENSION_TEST: "${{ matrix.system && '1' || '0' }}"
test_typing:
name: Test typing | ${{ matrix.kind }}
runs-on: ubuntu-latest
needs:
- build_sdist
- build_wheels
strategy:
fail-fast: false
matrix:
include:
- kind: sdist
artifact_name: "sdist"
file_pattern: "*.tar.gz"
- kind: wheel
artifact_name: "wheels Linux regular manylinux"
file_pattern: "*-cp313-cp313-manylinux*x86_64*.whl"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Restore build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ matrix.artifact_name }}
path: dist
- name: Install package
run: python -m pip install dist/${{ matrix.file_pattern }}
- name: Install mypy
run: python -m pip install mypy
- name: Test typing
run: mypy tests/test_integration.py
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
if:
startsWith(github.ref, 'refs/tags') &&
needs.define_build_wheels_matrix.outputs.full
needs:
- build_sdist
- build_wheels
- test_integration
- test_specific_python_versions
- test_debug
- test_system_zstd
- test_typing
environment: publish
permissions:
id-token: write # This permission is mandatory for trusted publishing
steps:
- name: Restore build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sdist
path: dist
- name: Restore build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: wheels*
path: dist
merge-multiple: true
- name: List distributions
run: ls -lR dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
verbose: true
print-hash: true