mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
feat(cli): publish a source distribution for lancedb-tools (#5314)
The `lancedb-tools` release contains wheels for Apple Silicon and two Linux architectures. Users on Intel macOS have no compatible wheel, so the Python installer has no way to install the CLI. This extends the release workflow from #5313 to build a source distribution from the same tag and check the source fallback before the release team approves publication. This was accomplished with the following changes: - Package the tagged Rust CLI, workspace manifests, lockfile, and licenses with a setuptools-rust binary target. - Install by package name on a native Intel macOS runner with all four release files available, then check that pip selected the sdist and built a working x86-64 executable. - Upload the tested sdist alongside the wheels and verify its published SHA-256 digest.
This commit is contained in:
@@ -26,7 +26,7 @@ permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
CLI_TAG: ${{ github.event.workflow_run.head_branch || inputs.tag || 'v0.42.0-beta.30' }}
|
||||
CLI_TAG: ${{ github.event.workflow_run.head_branch || inputs.tag || 'v0.42.1' }}
|
||||
|
||||
jobs:
|
||||
select-release:
|
||||
@@ -72,7 +72,7 @@ jobs:
|
||||
python-version: '3.13'
|
||||
- name: Test stable publishing checks
|
||||
run: bash ci/cli_wheel/test_publish_checks.sh
|
||||
- run: python -m pip install wheel==0.48.0
|
||||
- run: python -m pip install wheel==0.48.0 build
|
||||
- name: Build wheels from published release archives
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
@@ -80,6 +80,30 @@ jobs:
|
||||
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
|
||||
- name: Resolve the published CLI source
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
shell: bash
|
||||
run: |
|
||||
gh api "repos/lancedb/lancedb/releases/tags/$CLI_TAG" |
|
||||
jq -e --arg tag "$CLI_TAG" '.tag_name == $tag and .draft == false and .published_at != null'
|
||||
commit=$(gh api "repos/lancedb/lancedb/commits/refs/tags/$CLI_TAG" --jq .sha)
|
||||
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || exit 1
|
||||
if [[ -n "$RELEASE_SHA" && "$commit" != "$RELEASE_SHA" ]]; then
|
||||
echo "The release tag no longer points to the commit that published it." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "CLI_SOURCE_COMMIT=$commit" >> "$GITHUB_ENV"
|
||||
- name: Package source from the matching release tag
|
||||
run: |
|
||||
git fetch --depth=1 --no-tags https://github.com/lancedb/lancedb.git "$CLI_SOURCE_COMMIT"
|
||||
bash ci/cli_wheel/build_sdist.sh "$CLI_SOURCE_COMMIT" "$CLI_TAG" sdist
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: lancedb-tools-sdist
|
||||
path: sdist/*.tar.gz
|
||||
if-no-files-found: error
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: lancedb-tools-wheels
|
||||
@@ -109,6 +133,38 @@ jobs:
|
||||
- name: Install and exercise the native CLI with uvx and pipx
|
||||
run: bash ci/cli_wheel/test_install.sh "$CLI_TAG" "$PWD/wheels"
|
||||
|
||||
install-source:
|
||||
needs: build
|
||||
runs-on: macos-15-intel
|
||||
timeout-minutes: 180
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.13'
|
||||
- uses: ./.github/actions/setup-protoc
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: lancedb-tools-*
|
||||
merge-multiple: true
|
||||
path: dist
|
||||
- name: Install from the release distributions on Intel macOS
|
||||
shell: bash
|
||||
run: |
|
||||
test "$(uname -m)" = x86_64
|
||||
cd "$RUNNER_TEMP"
|
||||
python -m venv cli-env
|
||||
cli-env/bin/python -m pip download --only-binary=:all: --dest build-tools setuptools setuptools-rust wheel
|
||||
version=${CLI_TAG#v}
|
||||
cli-env/bin/python -m pip install -v --no-cache-dir --no-index --find-links build-tools \
|
||||
--find-links "$GITHUB_WORKSPACE/dist" --report install.json "lancedb-tools==${version/-beta./b}"
|
||||
jq -e 'any(.install[]; .metadata.name == "lancedb-tools" and (.download_info.url | endswith(".tar.gz")))' install.json
|
||||
test "$(lipo -archs cli-env/bin/lancedb)" = x86_64
|
||||
cli-env/bin/lancedb --version | grep -Fx "lancedb $version"
|
||||
cli-env/bin/lancedb profile list | grep -w local
|
||||
|
||||
check-publish:
|
||||
needs: build
|
||||
if: github.ref == 'refs/heads/main' && (github.event_name == 'workflow_run' || inputs.publish)
|
||||
@@ -127,7 +183,7 @@ jobs:
|
||||
|
||||
publish:
|
||||
name: Publish ${{ github.event.workflow_run.head_branch || inputs.tag }} to PyPI
|
||||
needs: [install, check-publish]
|
||||
needs: [install, install-source, check-publish]
|
||||
runs-on: ubuntu-24.04
|
||||
environment:
|
||||
name: pypi-cli
|
||||
@@ -138,19 +194,20 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: lancedb-tools-wheels
|
||||
pattern: lancedb-tools-*
|
||||
merge-multiple: true
|
||||
path: dist
|
||||
- name: Upload tested wheels
|
||||
- name: Upload tested distributions
|
||||
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
||||
with:
|
||||
# A retry of this job can finish a partially uploaded release.
|
||||
skip-existing: true
|
||||
- name: Verify the published wheel checksums
|
||||
- name: Verify the published distribution checksums
|
||||
working-directory: dist
|
||||
run: |
|
||||
curl --fail --silent --show-error --retry 5 --retry-all-errors \
|
||||
"https://pypi.org/pypi/lancedb-tools/${CLI_TAG#v}/json" -o "$RUNNER_TEMP/pypi.json"
|
||||
for wheel in *.whl; do
|
||||
digest=$(jq -er --arg wheel "$wheel" '.urls[] | select(.filename == $wheel) | .digests.sha256' "$RUNNER_TEMP/pypi.json")
|
||||
echo "$digest $wheel" | sha256sum --check
|
||||
for file in *.whl *.tar.gz; do
|
||||
digest=$(jq -er --arg file "$file" '.urls[] | select(.filename == $file) | .digests.sha256' "$RUNNER_TEMP/pypi.json")
|
||||
echo "$digest $file" | sha256sum --check
|
||||
done
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
commit=${1:?pass the resolved release commit}
|
||||
tag=${2:?pass the published release tag}
|
||||
out=${3:?pass the distribution output directory}
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
# Keep root-level build hooks and Python modules from the release out of the
|
||||
# build context. The Rust workspace is input data for the sdist.
|
||||
git archive --format=tar --output="$work/source.tar" "$commit" -- \
|
||||
.bumpversion.toml Cargo.toml Cargo.lock rust-toolchain.toml \
|
||||
LICENSE RUST_THIRD_PARTY_LICENSES.html README.md rust nodejs python docs/web-tests
|
||||
stage="$work/source"
|
||||
python -m tarfile --filter data -e "$work/source.tar" "$stage"
|
||||
python - "$stage" "$tag" <<'PY' > "$stage/CLI_VERSION"
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from ci.package_cli import release_version
|
||||
|
||||
print(release_version(Path(sys.argv[1]), f"refs/tags/{sys.argv[2]}"))
|
||||
PY
|
||||
cp ci/cli_wheel/sdist/{pyproject.toml,MANIFEST.in,CLI_README.md} "$stage/"
|
||||
python -I -m build --sdist --outdir "$out" "$stage"
|
||||
@@ -0,0 +1,7 @@
|
||||
# LanceDB CLI
|
||||
|
||||
Install with `pipx install lancedb-tools` or run `uvx --from lancedb-tools lancedb --help`.
|
||||
When a compatible wheel is unavailable, the Python installer builds the native
|
||||
`lancedb` executable with Cargo. Install Rust through rustup, a C/C++ toolchain,
|
||||
CMake and `protoc` before building. On Intel macOS, use the Xcode Command Line Tools.
|
||||
Cargo downloads the dependencies pinned in the release's `Cargo.lock`.
|
||||
@@ -0,0 +1,6 @@
|
||||
include Cargo.toml Cargo.lock rust-toolchain.toml CLI_VERSION
|
||||
graft rust
|
||||
# Cargo reads the manifests and targets of sibling workspace members when resolving the lockfile.
|
||||
recursive-include nodejs *.toml *.rs
|
||||
recursive-include python *.toml *.rs
|
||||
recursive-include docs/web-tests *.toml *.rs
|
||||
@@ -0,0 +1,26 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=68", "setuptools-rust>=1.9"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "lancedb-tools"
|
||||
dynamic = ["version"]
|
||||
description = "Command-line client for LanceDB SQL, profiles, and authentication"
|
||||
requires-python = ">=3.8"
|
||||
license = {text = "Apache-2.0"}
|
||||
readme = "CLI_README.md"
|
||||
|
||||
[project.urls]
|
||||
Source = "https://github.com/lancedb/lancedb"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = []
|
||||
license-files = ["LICENSE", "RUST_THIRD_PARTY_LICENSES.html"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {file = "CLI_VERSION"}
|
||||
|
||||
[[tool.setuptools-rust.bins]]
|
||||
target = "lancedb"
|
||||
path = "rust/lancedb/cli/Cargo.toml"
|
||||
cargo-manifest-args = ["--locked"]
|
||||
+9
-2
@@ -189,6 +189,13 @@ against `SHA256SUMS`, bundles the native executable and its notices, and saves t
|
||||
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 same run builds a source distribution from the tagged Rust workspace and
|
||||
saves it as `lancedb-tools-sdist`. Installers can compile the CLI locally when
|
||||
no wheel matches. Source builds need rustup, a C/C++ compiler, CMake, and
|
||||
`protoc`. The Intel macOS job installs by package name from the four release
|
||||
files and checks that the installer chose the source archive and built a
|
||||
working x86-64 executable.
|
||||
|
||||
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"`:
|
||||
@@ -207,9 +214,9 @@ wheel run, dispatch it from `main`:
|
||||
gh workflow run cli-wheels.yml --repo lancedb/lancedb --ref main -f tag=v0.42.0 -f publish=true
|
||||
```
|
||||
|
||||
After all three native install jobs pass, a member of the `release` team checks
|
||||
After the three wheel tests and the Intel macOS source install pass, a member of the `release` team checks
|
||||
the tag and install results and approves the `pypi-cli` deployment in the workflow run.
|
||||
The upload job publishes the tested wheels and verifies their SHA-256 digests
|
||||
The upload job publishes the tested wheels and source archive and verifies their SHA-256 digests
|
||||
against PyPI. If an upload stops partway, rerun the failed job in the same run
|
||||
to finish uploading the original wheels. To verify the public install:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user