name: Build Python Package
on:
pull_request:
types: [opened, ready_for_review, synchronize]
paths:
- 'python/**'
- 'src/python.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- 'pyproject.toml'
- '.github/workflows/python.yml'
push:
branches:
- main
paths:
- 'python/**'
- 'src/python.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- 'pyproject.toml'
- '.github/workflows/python.yml'
jobs:
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64
manylinux: 2_28
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build wheels (CPython only)
uses: PyO3/maturin-action@v1
env:
PYO3_CROSS_PYTHON_VERSION: "3.11"
with:
target: ${{ matrix.target }}
args: --release --out dist --features python,git,sql,rocksdb_storage --interpreter python3.11
sccache: 'true'
manylinux: ${{ matrix.manylinux }}
rust-toolchain: stable
before-script-linux: |
# librocksdb-sys needs:
# - clang/libclang for bindgen
# - a C++ toolchain (g++) to compile RocksDB itself
# - glibc-devel for `bits/libc-header-start.h` (missing in aarch64
# manylinux_2_28 by default; harmless on x86_64)
if command -v yum >/dev/null 2>&1; then
yum install -y clang gcc gcc-c++ glibc-devel
elif command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y --no-install-recommends clang g++ libc6-dev
fi
- name: Configure git identity for tests
if: runner.os == 'Linux'
run: |
git config --global user.name "CI Test"
git config --global user.email "ci@example.com"
- name: Install wheel and pytest
if: runner.os == 'Linux'
run: |
python -m pip install --upgrade pip
python -m pip install pytest
# Install the wheel built for this runner's platform.
WHEEL=$(ls dist/prollytree-*-cp38-abi3-manylinux*_${{ matrix.target }}.whl | head -1)
echo "Installing $WHEEL"
python -m pip install --force-reinstall "$WHEEL"
- name: Run Python tests (storage backends)
if: runner.os == 'Linux'
run: |
python -m pytest python/tests/test_versioned_kv.py -v
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.target }}
path: dist