feat(cli): package release binaries as lancedb-tools wheels (#5214)

Python users can install the LanceDB SDK today. This adds a separate
`lancedb-tools` distribution so they can also run the standalone
`lancedb` CLI with `uvx` or install it with `pipx`. The wheels bundle
the same binaries shipped through GitHub Releases for Apple Silicon
macOS, Linux ARM64, and Linux x86-64. The workflow uploads the wheels to
GitHub Actions for testing. PyPI publication will wait for a stable
release.

This was accomplished with the following changes:

- Verify the release archives against `SHA256SUMS` and bundle each
binary with its license and third-party notices in a platform-specific
wheel.
- Add the `lancedb` entry point and document how to build and test
wheels from a release tag.
- Exercise each wheel with both `uvx` and `pipx` on a native runner.

### Testing

All six installation checks passed against `v0.42.0-beta.30` (Python
version `0.42.0b30`). On Apple Silicon macOS, Linux ARM64, and Linux
x86-64, both `uvx` and `pipx` reported `lancedb 0.42.0-beta.30` and
listed the built-in local profile. [Native test results and wheel
artifacts](https://github.com/lancedb/lancedb/actions/runs/45680764524)

Locally verified that all three wheels contain byte-for-byte copies of
the released binary and license notices. All 38 tests in `ci/tests`
discovered by Python unittest passed.
This commit is contained in:
Bruno Ramirez
2026-11-25 11:39:12 -08:00
committed by GitHub
parent 60519d42ce
commit 06e626238d
5 changed files with 221 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
name: CLI Python wheels
on:
pull_request:
paths:
- ci/cli_wheel/**
- ci/build_cli_wheels.py
- ci/package_cli.py
- .github/workflows/cli-wheels.yml
workflow_dispatch:
inputs:
tag:
description: Published CLI release to package
required: true
default: v0.42.0-beta.30
permissions:
contents: read
env:
CLI_TAG: ${{ inputs.tag || 'v0.42.0-beta.30' }}
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- run: python -m pip install wheel==0.48.0
- name: Build wheels from published release archives
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo lancedb/lancedb --dir archives \
--pattern 'lancedb-*.tar.gz' --pattern SHA256SUMS -- "$CLI_TAG"
python -m ci.build_cli_wheels "$CLI_TAG" archives wheels
- uses: actions/upload-artifact@v7
with:
name: lancedb-tools-wheels
path: wheels/*.whl
if-no-files-found: error
compression-level: 0
install:
needs: build
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- uses: actions/download-artifact@v8
with:
name: lancedb-tools-wheels
path: wheels
- run: python -m pip install uv==0.13.9 pipx==1.19.0
- name: Install and exercise the native CLI with uvx and pipx
run: bash ci/cli_wheel/test_install.sh "$CLI_TAG" "$PWD/wheels"
+88
View File
@@ -0,0 +1,88 @@
"""Build lancedb-tools wheels from a complete, checksummed CLI release."""
import argparse
import re
import shutil
import subprocess
import sys
import tarfile
import tempfile
from pathlib import Path
from ci.package_cli import NOTICES, archive_stem, verify_checksums
PLATFORMS = {
"aarch64-apple-darwin": "macosx_14_0_arm64",
"aarch64-unknown-linux-gnu": "manylinux_2_28_aarch64",
"x86_64-unknown-linux-gnu": "manylinux_2_28_x86_64",
}
def build_wheels(tag: str, archives: Path, output: Path):
if not re.fullmatch(r"v[0-9]+\.[0-9]+\.[0-9]+(?:-beta\.[0-9]+)?", tag):
raise ValueError(f"Expected a stable or beta CLI release tag, got {tag!r}")
version = tag[1:]
wheel_version = version.replace("-beta.", "b")
verify_checksums(archives, version)
output.mkdir(parents=True, exist_ok=True)
for target, platform in PLATFORMS.items():
stem = archive_stem(version, target)
with tempfile.TemporaryDirectory(dir=output) as tmp:
stage = Path(tmp)
with tarfile.open(archives / f"{stem}.tar.gz", "r:gz") as archive:
archive.extractall(stage, filter="data")
root = stage / "wheel"
package = root / "lancedb_tools"
package.mkdir(parents=True)
(stage / stem / "lancedb").rename(package / "lancedb")
shutil.copyfile(
Path(__file__).parent / "cli_wheel/launcher.py", package / "__init__.py"
)
info = root / f"lancedb_tools-{wheel_version}.dist-info"
licenses = info / "licenses"
licenses.mkdir(parents=True)
for notice in NOTICES:
(stage / stem / notice).rename(licenses / notice)
(info / "METADATA").write_text(
"Metadata-Version: 2.4\n"
"Name: lancedb-tools\n"
f"Version: {wheel_version}\n"
"Summary: Command-line client for LanceDB SQL, profiles, and authentication\n"
"Requires-Python: >=3.8\n"
"License-Expression: Apache-2.0\n"
+ "".join(f"License-File: {notice}\n" for notice in NOTICES)
+ "Project-URL: Source, https://github.com/lancedb/lancedb\n"
"Description-Content-Type: text/plain\n\n"
"Run LanceDB SQL, manage connection profiles, and authenticate to a deployment.\n"
"Use pipx install lancedb-tools or uvx --from lancedb-tools lancedb --help.\n"
"Supports Apple Silicon on macOS 14+ and Linux ARM64 or x86-64 with glibc 2.28+.\n"
"Linux x86-64 requires AVX2, FMA, and F16C.\n"
)
(info / "WHEEL").write_text(
"Wheel-Version: 1.0\nGenerator: ci.build_cli_wheels\n"
f"Root-Is-Purelib: false\nTag: py3-none-{platform}\n"
)
(info / "entry_points.txt").write_text(
"[console_scripts]\nlancedb = lancedb_tools:main\n"
)
subprocess.run(
[sys.executable, "-m", "wheel", "pack", str(root), "-d", str(stage)],
check=True,
)
(wheel,) = stage.glob("*.whl")
wheel.replace(output / wheel.name)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("tag")
parser.add_argument(
"archives",
type=Path,
help="Directory with the three release archives and SHA256SUMS",
)
parser.add_argument("output", type=Path)
args = parser.parse_args()
build_wheels(args.tag, args.archives, args.output)
+20
View File
@@ -0,0 +1,20 @@
"""Console entry point for the bundled LanceDB CLI."""
import os
import platform
import sys
from pathlib import Path
def main():
if sys.platform == "linux" and platform.machine() == "x86_64":
# manylinux tags describe glibc and architecture, not CPU extensions.
with open("/proc/cpuinfo") as cpuinfo:
flags = next(
(line.split() for line in cpuinfo if line.startswith("flags")), []
)
if not {"avx2", "fma", "f16c"}.issubset(flags):
sys.exit("The LanceDB Linux x86-64 binary requires AVX2, FMA, and F16C.")
executable = Path(__file__).with_name("lancedb")
os.execv(executable, [str(executable), *sys.argv[1:]])
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Exercise resolver platform selection and both tools' installed entry points.
set -euo pipefail
tag=${1:?pass the CLI release tag}
wheels=${2:?pass the absolute wheel directory}
version=${tag#v}
spec="lancedb-tools==${version/-beta./b}"
test_env=$(mktemp -d)
trap 'rm -rf "$test_env"' EXIT
export XDG_CONFIG_HOME="$test_env/config" UV_CACHE_DIR="$test_env/uv"
export XDG_STATE_HOME="$test_env/state" XDG_DATA_HOME="$test_env/data"
export PIPX_HOME="$test_env/pipx" PIPX_BIN_DIR="$test_env/bin"
export PIPX_SHARED_LIBS="$test_env/shared" PIPX_MAN_DIR="$test_env/man"
check_cli() {
"$@" --version | grep -Fx "lancedb $version"
"$@" profile list | grep -w local
}
check_cli uvx --no-index --find-links "$wheels" --from "$spec" lancedb
python -m pip download --no-index --find-links "$wheels" --dest "$test_env/native" "$spec"
pipx install --backend pip "$test_env/native/"*.whl
check_cli "$PIPX_BIN_DIR/lancedb"
+21
View File
@@ -170,6 +170,27 @@ the publishing job replaces assets with matching names on an existing release.
Verify beta releases remain marked as prereleases and do not take the latest
release designation.
### Python CLI wheels
Run the **CLI Python wheels** workflow with a published CLI tag to build the
`lancedb-tools` wheels. It verifies the release archives against `SHA256SUMS`,
bundles the native executable and its notices, and saves the three wheels as
the `lancedb-tools-wheels` Actions artifact. Python package versions follow
PEP 440 (for example, CLI `v0.42.0-beta.30` becomes `0.42.0b30`).
The workflow tests `uvx` and `pipx` against the artifact on each supported
platform. To try a downloaded wheel on a matching machine, substitute its
local path for `"$wheel"`:
```sh
uvx --from "$wheel" lancedb --version
pipx install "$wheel"
lancedb profile list
```
This workflow produces review artifacts. Publishing the first stable wheels
to PyPI is a separate release step.
### Homebrew tap updates
After a stable GitHub release publishes, the `homebrew` job reads its