Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 85 additions & 25 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,113 @@ on:
- release

jobs:
publish:
runs-on: ubuntu-latest
build:
name: build-${{ matrix.name }}
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-24.04
target: x86_64
manylinux: "2_28"
wheel-pattern: "*manylinux_2_28_x86_64.whl"
extra-args: "--sdist"
- name: linux-aarch64
os: ubuntu-24.04
target: aarch64
manylinux: "2_28"
wheel-pattern: "*manylinux_2_28_aarch64.whl"
extra-args: ""
- name: macos-arm64
os: macos-14
target: aarch64-apple-darwin
wheel-pattern: "*macosx_11_0_arm64.whl"
extra-args: ""
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-C debuginfo=1"
RUST_BACKTRACE: "1"
CARGO_INCREMENTAL: "0"
MACOSX_DEPLOYMENT_TARGET: "11.0"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install macOS build dependencies
if: runner.os == 'macOS'
run: |
brew install protobuf

- name: Build Linux distributions
if: runner.os == 'Linux'
uses: PyO3/maturin-action@v1
with:
python-version: "3.11"
command: build
args: --release --out dist ${{ matrix.extra-args }}
working-directory: python
manylinux: ${{ matrix.manylinux }}
target: ${{ matrix.target }}
rust-toolchain: stable
before-script-linux: |
if command -v yum >/dev/null 2>&1; then
yum install -y curl make openssl-devel perl
elif command -v apt-get >/dev/null 2>&1; then
apt-get update
apt-get install -y curl libssl-dev ca-certificates make perl
fi
PROTOC_VERSION=25.6
curl -LsS -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
python3 - <<'PY'
from zipfile import ZipFile
ZipFile("/tmp/protoc.zip").extractall("/tmp/protoc")
PY
install -m 0755 /tmp/protoc/bin/protoc /usr/local/bin/protoc
cp -R /tmp/protoc/include/* /usr/local/include/
protoc --version

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Build macOS distributions
if: runner.os == 'macOS'
uses: PyO3/maturin-action@v1
with:
toolchain: stable
cache: false
command: build
args: --release --out dist ${{ matrix.extra-args }}
working-directory: python
target: ${{ matrix.target }}
rust-toolchain: stable

- name: Install system dependencies
- name: Verify wheel tag
run: |
sudo apt update
sudo apt install -y protobuf-compiler libssl-dev
ls python/dist/${{ matrix.wheel-pattern }}

- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-dist-${{ matrix.name }}
path: python/dist

- name: Install maturin
run: |
pip install maturin
publish:
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build distributions
working-directory: python
run: |
maturin build --release --out dist --sdist
- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Upload distributions
uses: actions/upload-artifact@v4
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-dist
pattern: python-dist-*
path: python/dist
merge-multiple: true

- name: Publish to PyPI
if: >
Expand Down
103 changes: 65 additions & 38 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,79 @@ env:

jobs:
build-wheel:
runs-on: ubuntu-24.04
name: build-wheel-${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-24.04
target: x86_64
manylinux: "2_28"
wheel-pattern: "*manylinux_2_28_x86_64.whl"
- name: linux-aarch64
os: ubuntu-24.04
target: aarch64
manylinux: "2_28"
wheel-pattern: "*manylinux_2_28_aarch64.whl"
- name: macos-arm64
os: macos-14
target: aarch64-apple-darwin
wheel-pattern: "*macosx_11_0_arm64.whl"
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false
- uses: Swatinem/rust-cache@v2
with:
shared-key: "lance-context-deps"
workspaces: |
crates/lance-context-core
python
- name: Install dependencies
- name: Install macOS build dependencies
if: runner.os == 'macOS'
run: |
sudo apt update
sudo apt install -y protobuf-compiler
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Setup sccache
uses: Mozilla-Actions/sccache-action@v0.0.9
- name: Configure sccache
run: echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- name: Cache uv downloads
uses: actions/cache@v4
brew install protobuf
- name: Build manylinux wheel (Debug Mode)
if: runner.os == 'Linux'
uses: PyO3/maturin-action@v1
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('python/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Build wheel (Debug Mode)
working-directory: python
command: build
args: --out dist
working-directory: python
manylinux: ${{ matrix.manylinux }}
target: ${{ matrix.target }}
rust-toolchain: stable
sccache: "true"
before-script-linux: |
if command -v yum >/dev/null 2>&1; then
yum install -y curl make openssl-devel perl
elif command -v apt-get >/dev/null 2>&1; then
apt-get update
apt-get install -y curl libssl-dev ca-certificates make perl
fi
PROTOC_VERSION=25.6
curl -LsS -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
python3 - <<'PY'
from zipfile import ZipFile
ZipFile("/tmp/protoc.zip").extractall("/tmp/protoc")
PY
install -m 0755 /tmp/protoc/bin/protoc /usr/local/bin/protoc
cp -R /tmp/protoc/include/* /usr/local/include/
protoc --version
- name: Build macOS wheel (Debug Mode)
if: runner.os == 'macOS'
uses: PyO3/maturin-action@v1
with:
command: build
args: --out dist
working-directory: python
target: ${{ matrix.target }}
rust-toolchain: stable
sccache: "true"
- name: Verify wheel tag
run: |
uv venv
source .venv/bin/activate
uv pip install maturin[patchelf]
maturin build -o dist
ls python/dist/${{ matrix.wheel-pattern }}
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: python-wheel
name: python-wheel-${{ matrix.name }}
path: python/dist/*.whl

test:
Expand Down Expand Up @@ -117,7 +144,7 @@ jobs:
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: python-wheel
name: python-wheel-linux-x86_64
path: python/dist
- name: Install wheel
working-directory: python
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,33 @@ python/tests/ # High-level integration tests

## Getting started

Install the Python package (wheel publishing coming soon):
Install the core Python package:

```bash
pip install lance-context
```

The default install supports context records, metadata, persistence, and
retrieval without installing the Python `lance-graph` package. Graph/Cypher
integrations can opt in explicitly:

```bash
pip install "lance-context[graph]"
```

Then follow the usage examples below to create a `Context`, append entries, and time-travel through versions.

### Python wheels

Release builds publish source distributions plus prebuilt wheels for:

- `manylinux_2_28_x86_64`
- `manylinux_2_28_aarch64`
- `macosx_11_0_arm64`

Other platforms can still install from the source distribution when a Rust
toolchain, maturin, and protobuf compiler are available.

## Usage

### Python
Expand Down
3 changes: 3 additions & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ lance-context-core = { path = "../crates/lance-context-core" }
pyo3 = { version = "0.25", features = ["extension-module", "abi3-py39", "py-clone"] }
serde_json = "1"
tokio = { version = "1", features = ["rt-multi-thread"] }

[target.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.dependencies]
openssl = { version = "0.10", features = ["vendored"] }
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies = [
"pylance==7.0.0",
"lancedb==0.27.1",
"lance-namespace==0.7.7",
"lance-graph==0.5.4",
]
description = "Multimodal, versioned context storage for agentic workflows"
authors = [{ name = "Lance Devs", email = "dev@lancedb.com" }]
Expand Down Expand Up @@ -41,6 +40,7 @@ requires = ["maturin>=1.4"]
build-backend = "maturin"

[project.optional-dependencies]
graph = ["lance-graph==0.5.4"]
# `moto[server]` pulls in flask + flask-cors so moto.server can be launched
# as a subprocess for the S3 integration tests.
tests = ["pytest", "pytest-asyncio", "ruff", "moto[s3,server]", "boto3", "botocore"]
Expand Down
10 changes: 6 additions & 4 deletions python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading