feat(python): add free-threaded CPython 3.15 wheel support (#4961)

## Problem

The existing `cp310-abi3` wheel cannot be installed on free-threaded
CPython 3.15.

## Changes

- Keep `abi3-py310` in the default Cargo feature set and provide a
separate native free-threaded build profile with the same Python
distribution features.
- Build and validate `cp315-cp315t` release wheels for Linux x86-64 and
ARM64, macOS ARM64, and Windows x64; collect them with the existing
release artifacts.
- Add a Linux 3.15t CI job and tests for GIL state, concurrent
operations, and persistence. The existing regular-Python jobs retain the
full test suite.
- Validate compressed manylinux platform tags against the expanded
`WHEEL` metadata and use workspace-relative wheel paths in Python CI.

## Validation

- Built and validated Windows x64
`lancedb-0.42.0b10-cp310-abi3-win_amd64.whl` and
`lancedb-0.42.0b10-cp315-cp315t-win_amd64.whl` with Maturin 1.15.0 and
`--profile ci`.
- On the current PR commit `eecf193`, rebuilt the Windows x64 native
wheel, installed it on official CPython 3.15.0t, and ran `python -m
pytest python/python/tests/test_free_threaded.py -q`: 2 passed,
including GIL state and concurrent database operations.
- On the current PR commit, built a native Linux x86-64 `cp315-cp315t`
wheel with Maturin 1.15.0 and `--profile ci`, validated its wheel
metadata, installed it on CPython 3.15.2t, and ran `python -m pytest
python/tests/test_free_threaded.py -q`: 2 passed. This local Linux wheel
uses the native `linux_x86_64` platform tag, not a manylinux tag.
- Cargo feature regression check, Ruff, Python syntax, workflow YAML
parsing, and `git diff --check` passed.
- `python -m unittest discover -s ci/tests -p test_check_python_wheel.py
-v`: 4 passed on Windows and WSL Linux, including compressed manylinux
tags and mismatched metadata. The workflow's corrected wheel glob was
also checked from the `python` directory under WSL, and the two
free-threaded runtime tests passed from that directory on Windows.

The local ABI3 regression wheel was built before the rebase. The native
Windows and Linux free-threaded wheels and concurrency tests were built
from the current PR commit `eecf193`. The macOS and Linux manylinux
release artifacts still need validation in upstream CI. The full test
extra pulls optional dependencies requiring source builds on 3.15t, so
the new job installs the wheel and focused test dependencies; regular
jobs still run the full suite.

The complete CI-script suite passed locally on WSL Linux at commit
`eecf193`: `python3 -m unittest discover -s ci/tests -v` ran 39 tests
successfully with Rust 1.97, a user-space GCC toolchain, and Python's
`packaging` module. The upstream CI-script run is marked
`action_required`.

Closes #4641
This commit is contained in:
David Turner
2026-11-30 21:07:25 +08:00
committed by GitHub
parent d9db83de65
commit c9faa78cc6
12 changed files with 643 additions and 25 deletions
@@ -3,12 +3,16 @@ name: build-linux-wheel
description: "Build a manylinux wheel for lance"
inputs:
python-minor-version:
description: "10, 11, 12, 13"
description: "Python minor version for the requested interpreter (e.g. 10, 13, 15)"
required: true
args:
description: "--release"
required: false
default: ""
maturin-version:
description: "Version of maturin to use for this wheel build"
required: false
default: "1.12.4"
arm-build:
description: "Build for arm64 instead of x86_64"
# Note: this does *not* mean the host is arm64, since we might be cross-compiling.
@@ -56,7 +60,7 @@ runs:
if: ${{ inputs.arm-build == 'false' }}
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
maturin-version: "1.12.4"
maturin-version: ${{ inputs.maturin-version }}
command: build
working-directory: python
docker-options: "-e PIP_EXTRA_INDEX_URL='https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/' -e PROTOC=/usr/local/bin/protoc -e PROTOC_VERSION=${{ steps.protoc.outputs.version }} -e PROTOC_SHA256=${{ steps.protoc.outputs.linux-x86_64-sha256 }} ${{ inputs.rustflags != '' && format('-e RUSTFLAGS={0}', inputs.rustflags) || '' }}"
@@ -74,7 +78,7 @@ runs:
if: ${{ inputs.arm-build == 'true' }}
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
maturin-version: "1.12.4"
maturin-version: ${{ inputs.maturin-version }}
command: build
working-directory: python
docker-options: "-e PIP_EXTRA_INDEX_URL='https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/' -e PROTOC=/usr/local/bin/protoc -e PROTOC_VERSION=${{ steps.protoc.outputs.version }} -e PROTOC_SHA256=${{ steps.protoc.outputs.linux-aarch_64-sha256 }} ${{ inputs.rustflags != '' && format('-e RUSTFLAGS={0}', inputs.rustflags) || '' }}"
+6 -2
View File
@@ -3,12 +3,16 @@ name: build_wheel
description: "Build a lance wheel"
inputs:
python-minor-version:
description: "10, 11, 12, 13"
description: "Python minor version for the requested interpreter (e.g. 10, 13, 15)"
required: true
args:
description: "--release"
required: false
default: ""
maturin-version:
description: "Version of maturin to use for this wheel build"
required: false
default: "1.12.4"
runs:
using: "composite"
steps:
@@ -17,7 +21,7 @@ runs:
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
command: build
maturin-version: "1.12.4"
maturin-version: ${{ inputs.maturin-version }}
# TODO: pass through interpreter
args: ${{ inputs.args }}
docker-options: "-e PIP_EXTRA_INDEX_URL='https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/'"
@@ -3,12 +3,16 @@ name: build_wheel
description: "Build a lance wheel"
inputs:
python-minor-version:
description: "10, 11, 12, 13, 14"
description: "Python minor version for the requested interpreter (e.g. 10, 14, 15)"
required: true
args:
description: "--release"
required: false
default: ""
maturin-version:
description: "Version of maturin to use for this wheel build"
required: false
default: "1.12.4"
runs:
using: "composite"
steps:
@@ -20,7 +24,7 @@ runs:
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
command: build
maturin-version: "1.12.4"
maturin-version: ${{ inputs.maturin-version }}
args: ${{ inputs.args }}
docker-options: "-e PIP_EXTRA_INDEX_URL='https://pypi.fury.io/lance-format/ https://pypi.fury.io/lancedb/'"
working-directory: python
+2
View File
@@ -9,6 +9,7 @@ on:
- python/pyproject.toml
- ci/check_cargo_lock.py
- ci/check_sdist.py
- ci/check_python_wheel.py
- ci/extract_sdk_doc_links.py
- ci/build_cli_linux.sh
- ci/package_cli.py
@@ -24,6 +25,7 @@ on:
- python/pyproject.toml
- ci/check_cargo_lock.py
- ci/check_sdist.py
- ci/check_python_wheel.py
- ci/extract_sdk_doc_links.py
- ci/build_cli_linux.sh
- ci/package_cli.py
+117 -2
View File
@@ -14,6 +14,7 @@ on:
- .github/actions/setup-protoc/action.yml
- ci/check_cargo_lock.py
- ci/check_sdist.py
- ci/check_python_wheel.py
- python/pyproject.toml
- python/Cargo.toml
- python/vendor/**
@@ -170,6 +171,113 @@ jobs:
name: wheels-windows
path: target/wheels/lancedb-*.whl
if-no-files-found: error
free-threaded-linux:
name: Python 3.15t Linux ${{ matrix.config.platform }}
timeout-minutes: ${{ matrix.config.platform == 'aarch64' && 150 || 90 }}
strategy:
fail-fast: false
matrix:
config:
- platform: x86_64
runner: ubuntu-2404-8x-x64
arm_build: false
- platform: aarch64
runner: ubuntu-2404-8x-arm64
arm_build: true
runs-on: ${{ matrix.config.runner }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Set up free-threaded Python
uses: actions/setup-python@v6
with:
python-version: "3.15t"
- name: Add swap for Arm fat LTO
if: matrix.config.platform == 'aarch64'
shell: bash
run: |
swap_file="$RUNNER_TEMP/lancedb-swap"
sudo fallocate --length 16G "$swap_file"
sudo chmod 600 "$swap_file"
sudo mkswap "$swap_file"
sudo swapon "$swap_file"
free -h
- uses: ./.github/workflows/build_linux_wheel
with:
python-minor-version: 15
maturin-version: "1.15.0"
arm-build: ${{ matrix.config.arm_build }}
manylinux: "2_28"
args: "--release --strip --interpreter python3.15t --no-default-features --features free-threaded,fp16kernels"
- name: Validate free-threaded wheel ABI and metadata
shell: bash
run: python ci/check_python_wheel.py cp315t --platform-fragment manylinux_2_28_${{ matrix.config.platform }} target/wheels/lancedb-*.whl
- uses: actions/upload-artifact@v7
if: startsWith(github.ref, 'refs/tags/v')
with:
name: wheels-free-threaded-linux-${{ matrix.config.platform }}
path: target/wheels/lancedb-*.whl
if-no-files-found: error
free-threaded-mac:
name: Python 3.15t macOS ARM64
timeout-minutes: 120
runs-on: warp-macos-14-arm64-6x
env:
MACOSX_DEPLOYMENT_TARGET: 10.15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Set up free-threaded Python
uses: actions/setup-python@v6
with:
python-version: "3.15t"
- uses: ./.github/workflows/build_mac_wheel
with:
python-minor-version: 15
maturin-version: "1.15.0"
args: "--release --strip --interpreter python3.15t --no-default-features --features free-threaded,fp16kernels"
- name: Validate free-threaded wheel ABI and metadata
shell: bash
run: python ci/check_python_wheel.py cp315t --platform-fragment macosx_11_0_arm64 target/wheels/lancedb-*.whl
- uses: actions/upload-artifact@v7
if: startsWith(github.ref, 'refs/tags/v')
with:
name: wheels-free-threaded-mac-aarch64
path: target/wheels/lancedb-*.whl
if-no-files-found: error
free-threaded-windows:
name: Python 3.15t Windows x64
timeout-minutes: 180
runs-on: windows-2025-8x-x64
env:
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Set up free-threaded Python
uses: actions/setup-python@v6
with:
python-version: "3.15t"
- uses: ./.github/workflows/build_windows_wheel
with:
python-minor-version: 15
maturin-version: "1.15.0"
args: "--release --strip --interpreter python3.15t --no-default-features --features free-threaded"
- name: Validate free-threaded wheel ABI and metadata
shell: bash
run: python ci/check_python_wheel.py cp315t --platform-fragment win_amd64 target/wheels/lancedb-*.whl
- uses: actions/upload-artifact@v7
if: startsWith(github.ref, 'refs/tags/v')
with:
name: wheels-free-threaded-windows-x86_64
path: target/wheels/lancedb-*.whl
if-no-files-found: error
sdist:
name: Python sdist
timeout-minutes: 60
@@ -256,7 +364,14 @@ jobs:
publish:
name: Publish wheels and sdist
if: startsWith(github.ref, 'refs/tags/v')
needs: [linux, mac, windows, sdist]
needs:
- linux
- mac
- windows
- free-threaded-linux
- free-threaded-mac
- free-threaded-windows
- sdist
runs-on: ubuntu-latest
permissions:
id-token: write
@@ -317,7 +432,7 @@ jobs:
report-failure:
name: Report Workflow Failure
runs-on: ubuntu-latest
needs: [linux, mac, windows, sdist, publish]
needs: [linux, mac, windows, sdist, publish, free-threaded-linux, free-threaded-mac, free-threaded-windows]
permissions:
contents: read
issues: write
+50 -3
View File
@@ -17,6 +17,7 @@ on:
- .github/workflows/build_windows_wheel/**
- .github/actions/setup-protoc/**
- .github/workflows/run_tests/**
- ci/check_python_wheel.py
permissions:
contents: read
@@ -156,6 +157,9 @@ jobs:
- uses: ./.github/workflows/build_linux_wheel
with:
args: --profile ci
- name: Validate wheel ABI and metadata
shell: bash
run: python ../ci/check_python_wheel.py abi3 --platform-fragment manylinux ../target/wheels/lancedb-*.whl
- uses: ./.github/workflows/run_tests
with:
integration: true
@@ -174,7 +178,44 @@ jobs:
--ignore=python/tests/test_query.py
# Make sure wheels are not included in the Rust cache
- name: Delete wheels
run: rm -rf target/wheels
run: rm -rf ../target/wheels
free-threaded:
name: "Linux: CPython 3.15t"
timeout-minutes: 90
runs-on: "ubuntu-24.04"
defaults:
run:
shell: bash
working-directory: python
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Set up free-threaded Python
uses: actions/setup-python@v6
with:
python-version: "3.15t"
- uses: ./.github/workflows/build_linux_wheel
with:
python-minor-version: 15
maturin-version: "1.15.0"
manylinux: "2_28"
args: --profile ci --interpreter python3.15t --no-default-features --features free-threaded
- name: Validate free-threaded wheel ABI and metadata
shell: bash
run: python ../ci/check_python_wheel.py cp315t --platform-fragment manylinux_2_28_x86_64 ../target/wheels/lancedb-*.whl
# The full test extra pins optional packages without 3.15t wheels. Keep
# the regular jobs running the full suite and exercise the installed
# free-threaded wheel with its runtime dependencies here.
- name: Install wheel and focused test dependencies
run: python -m pip install ../target/wheels/lancedb-*.whl pytest pytest-asyncio
- name: Test the installed wheel without the GIL
run: |
python -c "import sys, lancedb; assert not sys._is_gil_enabled()"
python -m pytest -q python/tests/test_free_threaded.py
- name: Delete wheels
run: rm -rf ../target/wheels
platform:
name: "Mac: ${{ matrix.features }}"
strategy:
@@ -207,10 +248,13 @@ jobs:
- uses: ./.github/workflows/build_mac_wheel
with:
args: --profile ci --features ${{ matrix.features }}
- name: Validate wheel ABI and metadata
shell: bash
run: python ../ci/check_python_wheel.py abi3 --platform-fragment macosx ../target/wheels/lancedb-*.whl
- uses: ./.github/workflows/run_tests
# Make sure wheels are not included in the Rust cache
- name: Delete wheels
run: rm -rf target/wheels
run: rm -rf ../target/wheels
windows:
name: "Windows: ${{ matrix.config.name }}"
timeout-minutes: 60
@@ -244,10 +288,13 @@ jobs:
- uses: ./.github/workflows/build_windows_wheel
with:
args: --profile ci
- name: Validate wheel ABI and metadata
shell: bash
run: python ../ci/check_python_wheel.py abi3 --platform-fragment win_amd64 ../target/wheels/lancedb-*.whl
- uses: ./.github/workflows/run_tests
# Make sure wheels are not included in the Rust cache
- name: Delete wheels
run: rm -rf target/wheels
run: rm -rf ../target/wheels
min-deps:
name: "Minimum dependencies"
timeout-minutes: 60