diff --git a/.github/workflows/pyo3-checks.yml b/.github/workflows/pyo3-checks.yml index 5303cd4d..61b825f4 100644 --- a/.github/workflows/pyo3-checks.yml +++ b/.github/workflows/pyo3-checks.yml @@ -76,22 +76,12 @@ jobs: strategy: fail-fast: false matrix: - # Cover the supported floor through the newest release. 3.13 - # and 3.14 exercise the GIL / free-threading changes where - # PyO3 extensions most often break. Floor is 3.9 — matches - # `requires-python` in pyo3/pyproject.toml. (3.9 also resolves - # 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. + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] + # Exercise the 26.0.0 floor as well as the latest compatible version. pyarrow: ["latest"] include: - - python-version: "3.12" - pyarrow: "23.0.1" + - python-version: "3.11" + pyarrow: "26.0.0" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -207,12 +197,12 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] + python-version: ["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" + - python-version: "3.11" + pyarrow: "26.0.0" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/CLAUDE.md b/CLAUDE.md index f5123a2d..07aad87b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -124,7 +124,7 @@ How this shows up in the repo: - **Python dep pinning follows the externally-published-library rule from [go/pinning-python-deps](https://docs.google.com/document/d/1thJsoOBW3NzvRV6pWpujcD8mn4KOXgAW8t10iw6Z6LA/edit)**: major-version upper bounds in `pyo3/pyproject.toml` - (`pyarrow>=14,<19`), no exact pins, no transitive constraints, + with no exact pins, no transitive constraints, no committed lockfile. Exact pins would impede downstream `pip install databricks-sql-kernel` for end-users with their own pyarrow consumers. Trusted jobs use `db-pypi`, whose 7-day age filter is diff --git a/pyo3/Cargo.toml b/pyo3/Cargo.toml index 7b6270f2..b4caf012 100644 --- a/pyo3/Cargo.toml +++ b/pyo3/Cargo.toml @@ -74,12 +74,8 @@ extension-module = ["pyo3/extension-module"] # kernel's default feature. databricks-sql-kernel = { path = "..", default-features = false, features = ["tls-rustls"] } -# pyo3 — abi3-py39 builds a single stable-ABI wheel (tagged -# cp39-abi3) that loads on CPython 3.9+. The ABI floor is kept in -# step with `requires-python = ">=3.9"` in pyproject.toml; bumping -# both together avoids shipping a wheel whose ABI tag advertises an -# interpreter the package no longer claims to support. -pyo3 = { version = "0.29", features = ["abi3-py39"] } +# Match the stable ABI floor to the minimum supported Python version. +pyo3 = { version = "0.29", features = ["abi3-py310"] } # Multi-thread runtime — one per Session, owned on the Rust side. tokio = { version = "1", features = ["rt-multi-thread"] } diff --git a/pyo3/NEXT_CHANGELOG.md b/pyo3/NEXT_CHANGELOG.md index d8233cd8..11aea651 100644 --- a/pyo3/NEXT_CHANGELOG.md +++ b/pyo3/NEXT_CHANGELOG.md @@ -18,12 +18,10 @@ 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. +- The Python wheel now requires Python 3.10 or newer. +- On Python 3.11 and newer, the kernel now requires PyArrow 26.x, which fixes + CVE-2026-92287. Because PyArrow 26 requires at least Python 3.11, the kernel + continues to support PyArrow 23.0.1 through 25.x on Python 3.10. ### Updated diff --git a/pyo3/pyproject.toml b/pyo3/pyproject.toml index 9d8c1109..8684438a 100644 --- a/pyo3/pyproject.toml +++ b/pyo3/pyproject.toml @@ -6,37 +6,13 @@ build-backend = "maturin" name = "databricks-sql-kernel" version = "1.5.0" description = "Python bindings for the Databricks SQL Kernel (PyO3)" -# Floor matches the tested CI matrix in -# .github/workflows/pyo3-checks.yml (3.9 .. 3.14). The abi3-py39 -# wheel (see pyo3/Cargo.toml) loads on every CPython at or above -# this floor from a single artifact. -requires-python = ">=3.9" +requires-python = ">=3.10" license = { text = "Apache-2.0" } authors = [{ name = "Databricks" }] -# Runtime dependency for downstream consumers. Major-version bound -# per the go/pinning-python-deps externally-published-library rule: -# exact pins make this wheel harder for end-users to install -# alongside their own pyarrow consumers. The CI environment also -# uses these bounds (no committed lockfile) — see the -# `[dependency-groups].dev` block below + the workflow comment in -# `.github/workflows/pyo3-checks.yml` for the policy rationale. -# -# Split by interpreter via PEP 508 environment markers because the -# two ends of the supported range need different pyarrow floors: -# -# * 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 `<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). +# PyArrow 26 fixes CVE-2026-92287 and requires Python 3.11 or newer. dependencies = [ - "pyarrow>=23.0.1,<27; python_version >= '3.10'", - "pyarrow>=14,<19; python_version < '3.10'", + "pyarrow>=23.0.1,<26; python_version == '3.10'", + "pyarrow>=26,<27; python_version >= '3.11'", ] # Dev / CI dependencies. PEP 735 standard; uv reads this directly. diff --git a/pyo3/src/errors.rs b/pyo3/src/errors.rs index 88ff4257..26397390 100644 --- a/pyo3/src/errors.rs +++ b/pyo3/src/errors.rs @@ -18,7 +18,7 @@ //! Subclassing native exception types is not allowed in `abi3` mode //! (PyO3 emits a compile-time error: "with the abi3 feature enabled, //! PyO3 does not support subclassing native types"). To keep one -//! wheel per platform across Python 3.9+, `KernelError` is built +//! wheel per platform across supported Python versions, `KernelError` is built //! via `create_exception!` (subclasses `Exception` at the Python C //! level, not at the Rust pyclass level) and the structured fields //! are attached as Python attributes via `setattr` so callers still diff --git a/pyo3/src/logging.rs b/pyo3/src/logging.rs index cdb331c6..bf4f9940 100644 --- a/pyo3/src/logging.rs +++ b/pyo3/src/logging.rs @@ -65,7 +65,7 @@ //! //! Runtime workers can outlive their handle (`KernelRuntime`'s `Drop` //! doesn't wait for them), and pyo3's finalization check is compiled out -//! under `abi3-py39`, so a worker forwarding a record while the +//! at our stable ABI floor, so a worker forwarding a record while the //! interpreter finalizes can abort the process. An `atexit` hook, which //! runs before finalization starts, makes the bridge drop records from //! then on. diff --git a/pyo3/tests/test_dependency_bounds.py b/pyo3/tests/test_dependency_bounds.py index 3609f9cd..efe6a76f 100644 --- a/pyo3/tests/test_dependency_bounds.py +++ b/pyo3/tests/test_dependency_bounds.py @@ -22,27 +22,23 @@ 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.""" +def pyarrow_requirement(environment: dict[str, str] | None = None) -> Requirement: + """Return the wheel's PyArrow requirement for the given environment.""" 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()) + if req.name == "pyarrow" + and (req.marker is None or req.marker.evaluate(environment)) ] assert len(matching) == 1, ( - f"expected one pyarrow requirement for this interpreter, got {matching}" + f"expected one active pyarrow requirement, got {matching}" ) return matching[0] @@ -54,10 +50,18 @@ def test_installed_pyarrow_satisfies_declared_range(): ) -@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" +@pytest.mark.parametrize( + ("python_version", "accepted", "rejected"), + [ + ("3.10", ["23.0.1", "24.0.0", "25.0.1"], ["23.0.0", "26.0.0"]), + ("3.11", ["26.0.0", "26.0.1"], ["23.0.1", "25.0.1", "27.0.0"]), + ], +) +def test_wheel_pyarrow_bounds(python_version, accepted, rejected): + req = pyarrow_requirement( + {"python_version": python_version, "python_full_version": f"{python_version}.0"} ) + for version in accepted: + assert version in req.specifier + for version in rejected: + assert version not in req.specifier