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
30 changes: 28 additions & 2 deletions .github/workflows/pyo3-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ defaults:

jobs:
build-and-test:
name: "PyO3 build + test (Python ${{ matrix.python-version }})"
name: "PyO3 build + test (Python ${{ matrix.python-version }}${{ matrix.pyarrow != 'latest' && format(', pyarrow {0}', matrix.pyarrow) || '' }})"
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
Expand Down Expand Up @@ -83,6 +83,15 @@ jobs:
# the older `pyarrow>=14,<19` series via the env-marker split
# in pyproject.toml, exercising that path in CI.)
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
# `uv sync` resolves the newest pyarrow inside the declared bound,
# so the default legs only ever see the top of `>=23.0.1,<27`.
# The include below adds one leg pinned to the floor, so a kernel
# change that breaks on the oldest supported pyarrow fails CI
# instead of a user's install.
pyarrow: ["latest"]
include:
- python-version: "3.12"
pyarrow: "23.0.1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Expand Down Expand Up @@ -161,6 +170,13 @@ jobs:
# asks maturin to build and install it a second time.
run: uv run --no-sync maturin develop

- name: Pin pyarrow to the declared floor
if: matrix.pyarrow != 'latest'
working-directory: pyo3
# Pin after maturin installs dependencies so a stale floor fails the
# installed-dependency check instead of being silently upgraded.
run: uv pip install "pyarrow==${{ matrix.pyarrow }}"

- name: pytest (no-network + live tiers)
working-directory: pyo3
# `conftest.py` decorates the warehouse-bound tests with
Expand All @@ -177,7 +193,7 @@ jobs:
# intentionally substitutes the credential-free package proxies and omits
# the azure-prod environment, its secrets, and the live-test tier.
fork-build-and-test:
name: "PyO3 build + test (Python ${{ matrix.python-version }})"
name: "PyO3 build + test (Python ${{ matrix.python-version }}${{ matrix.pyarrow != 'latest' && format(', pyarrow {0}', matrix.pyarrow) || '' }})"
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
permissions:
contents: read
Expand All @@ -192,6 +208,11 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
# Same floor leg as `build-and-test`; see the comment there.
pyarrow: ["latest"]
include:
- python-version: "3.12"
pyarrow: "23.0.1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Expand Down Expand Up @@ -228,6 +249,11 @@ jobs:
working-directory: pyo3
run: uv run --no-sync maturin develop

- name: Pin pyarrow to the declared floor
if: matrix.pyarrow != 'latest'
working-directory: pyo3
run: uv pip install "pyarrow==${{ matrix.pyarrow }}"

- name: Run no-network tests
working-directory: pyo3
run: uv run --no-sync pytest -v
6 changes: 6 additions & 0 deletions pyo3/NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ changes go in the root `NEXT_CHANGELOG.md`.
raises `KernelError` (`InvalidArgument`).

### Changed
- Allow pyarrow 24.x through 26.x on Python 3.10+ (`pyarrow>=23.0.1,<27`),
so the wheel installs alongside pyarrow 26, the first release clear of
CVE-2026-92287. Fresh `[kernel]` installs without their own pyarrow pin now
resolve pyarrow 26 on Python 3.11+ (25.x on 3.10); pin `pyarrow<24` to stay
on 23.x. Python 3.9/3.10 have no fixed pyarrow release available;
upgrade to Python 3.11+ to clear the CVE.

### Updated

Expand Down
16 changes: 8 additions & 8 deletions pyo3/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ authors = [{ name = "Databricks" }]
# Split by interpreter via PEP 508 environment markers because the
# two ends of the supported range need different pyarrow floors:
#
# * Python 3.10+: `>=23.0.1` matches databricks-sql-connector 5.0.0
# (databricks/databricks-sql-python#818). pyarrow only ships cp314
# (Python 3.14) wheels from 23.x onward, so an older ceiling forces
# a from-source build that fails on 3.14. Keeping the floor aligned
# with the connector also keeps the two surfaces installable side
# by side.
# * Python 3.10+: retain the connector's >=23.0.1 floor; <27 admits
# the CVE-2026-92287 fix in 26.x, which requires Python 3.11+.
# Python 3.10 resolves to 25.x.
# * Python 3.9: pyarrow 23.x dropped 3.9 wheels, so 3.9 takes the
# last series that still ships them (`>=14,<19`). 3.9 never sees
# 3.14, so the cp314 concern does not apply here.
#
# Both `<24` / `<19` ceilings preserve the major-version upper bound
# Both `<27` / `<19` ceilings preserve the major-version upper bound
# the go/pinning-python-deps policy requires (a future pyarrow major
# then surfaces as a deliberate bump, not a silent auto-resolve).
dependencies = [
"pyarrow>=23.0.1,<24; python_version >= '3.10'",
"pyarrow>=23.0.1,<27; python_version >= '3.10'",
Comment thread
shiminlin-db marked this conversation as resolved.
Resolved
"pyarrow>=14,<19; python_version < '3.10'",
]

Expand All @@ -53,6 +50,9 @@ dependencies = [
dev = [
"maturin>=1.7,<2.0",
"pytest>=8.3,<9.0",
# tests/test_dependency_bounds.py parses Requires-Dist with it; pytest
# happens to pull it in, but the test must not rely on that.
"packaging>=24,<27",
]

[tool.maturin]
Expand Down
63 changes: 63 additions & 0 deletions pyo3/tests/test_dependency_bounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) 2026 Databricks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Published dependency bounds of the wheel.

The pyarrow range is the only dependency metadata end-users resolve
against, so these tests read the installed distribution's
``Requires-Dist`` (what ``maturin develop`` / ``pip`` see) rather than
``pyproject.toml``.
"""

from __future__ import annotations

import sys
from importlib.metadata import requires

import pyarrow
import pytest
from packaging.requirements import Requirement
from packaging.version import Version

# First pyarrow release without CVE-2026-92287 (apache/arrow#51349).
PYARROW_CVE_2026_92287_FIXED = Version("26.0.0")


def pyarrow_requirement() -> Requirement:
"""The pyarrow requirement whose environment marker matches this interpreter."""
matching = [
req
for req in (Requirement(r) for r in requires("databricks-sql-kernel") or [])
if req.name == "pyarrow" and (req.marker is None or req.marker.evaluate())
]
assert len(matching) == 1, (
f"expected one pyarrow requirement for this interpreter, got {matching}"
)
return matching[0]


def test_installed_pyarrow_satisfies_declared_range():
req = pyarrow_requirement()
assert req.specifier.contains(pyarrow.__version__, prereleases=True), (
f"installed pyarrow {pyarrow.__version__} is outside the declared range {req.specifier}"
)


@pytest.mark.skipif(sys.version_info < (3, 10), reason="Python 3.9 caps pyarrow at <19")
def test_declared_range_admits_pyarrow_clear_of_cve_2026_92287():
req = pyarrow_requirement()
assert req.specifier.contains(PYARROW_CVE_2026_92287_FIXED), (
f"declared range {req.specifier} excludes pyarrow {PYARROW_CVE_2026_92287_FIXED}; "
"consumers could not install a pyarrow clear of CVE-2026-92287"
)
Loading