name: Python Bindings
on:
workflow_dispatch:
pull_request:
paths:
- "bindings/python/**"
- "integrations/llama-index-graph-stores-hawdb/**"
- "integrations/dify-plugin-hawdb/**"
- "crates/core/src/error.rs"
- "MODULE.bazel"
- "BUILD.bazel"
- ".bazelrc"
- ".cargo/**"
- ".bazelversion"
- ".github/workflows/python-bindings.yml"
push:
branches: [main]
paths:
- "bindings/python/**"
- "integrations/llama-index-graph-stores-hawdb/**"
- "integrations/dify-plugin-hawdb/**"
- "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.99.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, error retry classification and SQL admission
run: cargo test --release --locked --lib -- retained::arrow::destructor_tests errors::tests database::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
- name: Provision the optional LlamaIndex consumer
if: matrix.os == 'ubuntu-24.04'
run: |
pip install "llama-index-core==0.14.25"
# Keep the wheel built above instead of a hawdb release from PyPI.
pip install --no-deps ../../integrations/llama-index-graph-stores-hawdb
pip check
- name: Test the LlamaIndex property graph store against the installed wheel
if: matrix.os == 'ubuntu-24.04'
run: pytest ../../integrations/llama-index-graph-stores-hawdb/tests
- name: Install Python 3.12 for the optional Dify plugin
id: python-dify
if: matrix.os == 'ubuntu-24.04'
uses: actions/setup-python@v7
with:
python-version: "3.12"
update-environment: false
- name: Provision the optional Dify plugin
if: matrix.os == 'ubuntu-24.04'
run: |
"${{ steps.python-dify.outputs.python-path }}" -m venv "$RUNNER_TEMP/dify"
# Keep the wheel built above instead of a hawdb release from PyPI.
"$RUNNER_TEMP/dify/bin/python" -m pip install dist/*.whl "dify_plugin==0.11.0" "pytest>=8.0"
"$RUNNER_TEMP/dify/bin/python" -m pip check
- name: Test the Dify plugin against the installed wheel
if: matrix.os == 'ubuntu-24.04'
run: '"$RUNNER_TEMP/dify/bin/pytest" ../../integrations/dify-plugin-hawdb/tests'
- name: Retain the tested native wheel for host verification
uses: actions/upload-artifact@v7
with:
name: python-wheel-${{ runner.os }}-${{ github.sha }}
path: bindings/python/dist/*.whl
if-no-files-found: error
retention-days: 7