name: Python Bindings
on:
workflow_dispatch:
pull_request:
paths:
- "bindings/python/**"
- "crates/core/src/error.rs"
- "MODULE.bazel"
- "BUILD.bazel"
- ".bazelrc"
- ".cargo/**"
- ".bazelversion"
- ".github/workflows/python-bindings.yml"
push:
branches: [main]
paths:
- "bindings/python/**"
- "crates/core/src/error.rs"
- "MODULE.bazel"
- "BUILD.bazel"
- ".bazelrc"
- ".cargo/**"
- ".bazelversion"
- ".github/workflows/python-bindings.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
bazel:
name: Bazel build and test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest]
env:
USE_BAZEL_VERSION: "9.3.1"
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Bazel
uses: bazel-contrib/setup-bazel@0.19.1
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}-${{ github.job }}
repository-cache: true
external-cache: true
- name: Build the Python package and native extension
run: bazel build //bindings/python:hawdb
- name: Test the Bazel extension and dependency lock
run: bazel test //bindings/python/...
test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
name: Build and test
- os: windows-2025
name: Windows Python wheel
defaults:
run:
shell: bash
working-directory: bindings/python
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@1.97.1
with:
components: clippy, rustfmt
- name: Install Python
uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Install maturin and pytest
run: pip install "maturin==1.15.0" "pytest>=8.0"
- name: Validate the reviewed binding dependency lock
run: |
python -m unittest test_check_lock
python check_lock.py --root ../../Cargo.lock --binding Cargo.lock
- name: Check the independent binding workspace
run: |
cargo fmt --all -- --check
cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Build the extension wheel
run: maturin build --release --locked --out dist
- name: Test capsule unwind containment and error retry classification
run: cargo test --release --locked --lib -- retained::arrow::destructor_tests errors::tests --test-threads=1
- name: Install the built wheel
run: pip install dist/*.whl
- name: Run tests
run: pytest tests
- name: Install the pydantic extra
run: pip install "$(echo dist/*.whl)[pydantic]"
- name: Run tests with the pydantic extra
run: pytest tests/test_pydantic*.py
- name: Provision the optional public Arrow consumer
if: matrix.os == 'ubuntu-24.04'
run: pip install "pyarrow==26.0.0"
- name: Test public Arrow protocols against the installed wheel
if: matrix.os == 'ubuntu-24.04'
run: |
python -c 'import pyarrow; print(pyarrow.__version__)'
pytest tests/test_arrow_consumer.py
- name: Provision the optional pandas DB-API consumer
if: matrix.os == 'ubuntu-24.04'
run: pip install "pandas==3.1.0"
- name: Test pandas.read_sql over the DB-API against the installed wheel
if: matrix.os == 'ubuntu-24.04'
run: |
python -c 'import pandas; print(pandas.__version__)'
pytest tests/test_dbapi.py -k pandas