Skip to content

build(pyo3): build against the kernel with tls-rustls, not tls-native - #124

Merged
gopalldb merged 3 commits into
mainfrom
ci/pyo3-tls-rustls
Jun 4, 2026
Merged

gopalldb merged 3 commits into
mainfrom
ci/pyo3-tls-rustls

Conversation

@gopalldb

@gopalldb gopalldb commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The pyo3 wheel is built inside a manylinux_2_28 container (in secure-public-registry-releases-eng's peco-databricks-sql-kernel-python release workflow) that ships no OpenSSL. The kernel's default tls-native feature pulls in reqwest/native-tls → openssl-sys, which fails to compile there:

The system library `openssl` required by crate `openssl-sys` was not found.
HINT: you may need to install a package such as openssl-devel

This change disables the kernel's default feature on the pyo3 dependency and opts into tls-rustls (pure-Rust rustls + ring) — exactly as the napi crate already does. No system OpenSSL is needed and the published wheel stays self-contained / portable.

Direct-Rust users and the C-ABI (future ODBC) keep tls-native via the kernel's default feature; only the pyo3 binding opts out.

Change

# pyo3/Cargo.toml
-databricks-sql-kernel = { path = ".." }
+databricks-sql-kernel = { path = "..", default-features = false, features = ["tls-rustls"] }

(Mirrors napi/Cargo.toml, which already uses default-features = false, features = ["tls-rustls"].)

Verification

  • cargo check -p databricks-sql-kernel-pyo3 passes.
  • cargo tree -p databricks-sql-kernel-pyo3 -i openssl-sys → "did not match any packages" (openssl-sys fully removed; rustls throughout the tree).
  • Cargo.lock unchanged.

Note: a bare cargo build of the pyo3 cdylib fails to link (_Py_NoneStruct etc.) — that's the normal pyo3 extension-module behavior (CPython symbols resolve at import time via maturin's linker args), unrelated to this change.

Follow-up

Once this lands and a new kernel tag is cut, the peco-databricks-sql-kernel-python release workflow's Linux (manylinux) wheel builds will compile cleanly — this was the last blocker for that pipeline.

This pull request and its description were written by Isaac.

gopalldb added 2 commits June 4, 2026 21:59
The pyo3 wheel is built inside a manylinux container that ships no
OpenSSL, so the kernel's default `tls-native` feature (reqwest's
native-tls -> openssl-sys) fails to compile:

  The system library `openssl` required by crate `openssl-sys` was not found.

Disable the kernel's default feature and opt into `tls-rustls`
(pure-Rust rustls + ring) on the pyo3 dependency, exactly as the napi
crate already does. No system OpenSSL is needed and the published wheel
stays self-contained / portable.

Direct-Rust users and the C-ABI keep `tls-native` via the kernel's
default feature; only the pyo3 binding opts out.

Verified: `cargo check -p databricks-sql-kernel-pyo3` passes and
`cargo tree -i openssl-sys` now matches no packages (rustls throughout).

Co-authored-by: Isaac
Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
…LS feature

The previous commit changed `pyo3/Cargo.toml`'s kernel dep to
`default-features = false, features = ["tls-rustls"]`. While pyo3
was a member of the kernel's root workspace, `cargo build/test
--workspace` (run by `pr-checks.yml`'s `cargo test` job and
`coverage.yml`'s `cargo llvm-cov`) unified the kernel's feature set
to `tls-native ∪ tls-rustls` across all workspace members and
tripped the mutual-exclusion `compile_error!` in `src/lib.rs:87`:

  error: `tls-native` and `tls-rustls` are mutually exclusive —
  enabling both links two TLS stacks and defeats the napi crate's
  rustls switch.

The kernel root's existing comment on `[workspace]` already
explained why napi is NOT a workspace member (same feature-union
reason). With pyo3 now ALSO needing `tls-rustls`, it has the same
constraint and the same fix: standalone workspace.

Changes:

- `Cargo.toml`: `members = ["."]` (was `[".", "pyo3"]`). Header
  comment updated to describe both pyo3 and napi as standalone
  workspaces with the same per-binding-TLS rationale.
- `pyo3/Cargo.toml`: add a `[workspace] members = ["."]` block
  with a comment mirroring `napi/Cargo.toml`'s rationale.
- `pyo3/Cargo.lock`: new (pyo3 now has its own lockfile, same as
  `napi/Cargo.lock`).
- `Cargo.lock`: shrinks by ~148 lines (pyo3-only deps moved to
  `pyo3/Cargo.lock`).
- `.github/workflows/pyo3-checks.yml`: `cargo test -p
  databricks-sql-kernel-pyo3` (run from repo root, relied on
  workspace membership) → `cargo test` with `working-directory:
  pyo3`. Mirrors how the napi workflow invokes cargo.

Verified locally:
- `cargo test --workspace --lib` from root: 620/620 lib tests pass.
- `cargo clippy --all-targets -- -D warnings` clean (root + pyo3).
- `cargo +stable fmt --all` clean.

Also fixes the DCO sign-off on the previous commit
(`c21d0b2` → amended to `bfd7090`).

Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
After splitting pyo3 into a standalone workspace (commit efd5002),
the security-scan workflow's `cargo cyclonedx` invocation at the
kernel root no longer walks the pyo3 sub-crate — the kernel root's
workspace now has `members = ["."]`, so cyclonedx emits one SBOM
(kernel root) instead of two (kernel + pyo3). The downstream
`test … -ge 3` count check then fails:

  expected >=3 SBOMs (root crate + pyo3 + napi), got 2

Fix: invoke `cargo cyclonedx` once per workspace — once at the
root, once from `pyo3/`, once from `napi/`. This mirrors the
napi pattern that was already in place.

Also rewrite the workflow header comment + step comment to
describe the new three-standalone-workspaces shape, so a future
reader doesn't have to reverse-engineer the rationale from
behaviour.

Verified locally — the SBOM-gen block now produces:
  databricks-sql-kernel.cdx.json       (kernel root)
  databricks-sql-kernel-pyo3.cdx.json  (pyo3 standalone workspace)
  databricks-sql-kernel-napi.cdx.json  (napi standalone workspace)

YAML validates.

Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
Merged via the queue into main with commit 807b8db Jun 4, 2026
24 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — fa2d4fe4 Deployed Jun 4, 2026 by gopalldb via PyO3 build + test (Python 3.13) #78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants