Skip to content

ci: pin Rust toolchain via rust-toolchain.toml and simplify CI#1868

Draft
AdilZouitine wants to merge 2 commits into
maturin/03-submodulesfrom
maturin/04-rust-toolchain
Draft

ci: pin Rust toolchain via rust-toolchain.toml and simplify CI#1868
AdilZouitine wants to merge 2 commits into
maturin/03-submodulesfrom
maturin/04-rust-toolchain

Conversation

@AdilZouitine
Copy link
Copy Markdown
Member

@AdilZouitine AdilZouitine commented May 12, 2026

What & Why

Two related cleanups land together. First, the crate uses no nightly features (grep -rn '#!\\[feature(' rust_src/ returns nothing), so the cibuildwheel overrides that installed nightly Rust were wasted CI time and a source of nightly-churn flakes. Second, the right way to communicate the required toolchain to both developers and CI is a rust-toolchain.toml file at the repo root: rustup reads it automatically on the first cargo invocation and installs the pinned channel and targets. Once that file exists, the cibuildwheel before-build hooks collapse to "install rustup, then do nothing else".

How

  1. New rust-toolchain.toml at repo root: channel = "stable", components = ["rustfmt", "clippy"], profile = "minimal", and the three cross-compile targets we need (aarch64-apple-darwin, x86_64-apple-darwin, i686-pc-windows-msvc).
  2. pyproject.toml:
    • Linux override: install rustup with --default-toolchain=none --profile=minimal. The toolchain file picks the channel and targets on first cargo invocation.
    • macOS and Windows overrides collapse to rustup show (those runners come with rustup preinstalled; rustup show is enough to trigger the toolchain-file resolution and log the resolved state).
    • Drop CARGO_NET_GIT_FETCH_WITH_CLI = "true" from [tool.cibuildwheel.linux.environment]: setuptools-rust-era workaround the maturin build doesn't need.
  3. CLAUDE.md: one-line note next to the uv sync block explaining the toolchain pin.

No changes to .github/workflows/; cibuildwheel reads pyproject.toml directly.

Testing

  • rustup show reports "stable-aarch64-apple-darwin (overridden by '…/rust-toolchain.toml')".
  • cargo build --release and cargo bench --no-run build cleanly under the pinned channel.
  • TODO before merge: trigger the pypi workflow on this branch via workflow_dispatch and confirm every matrix cell succeeds with the simplified before-build blocks. (Linux × {manylinux, musllinux} × py311-py314 × {x86_64, aarch64}; macOS-15 × py311-py314; Windows-2025 × py311-py314.)

Notes for reviewers

  • Two changes land together because the toolchain file makes the nightly drop almost free: instead of editing three different rustup invocations across the override blocks, the channel is centralised in one file and the overrides shrink to almost nothing. Splitting these into two PRs would create more churn than it saves.
  • The Linux before-build still installs rustup because the manylinux container has no rust at all. macOS-15 and windows-2025 runners ship with rustup; for those, the override is just rustup show so the build log captures what's about to be used.
  • A successful workflow_dispatch run on the PR branch is required to merge: the regular per-PR dev.yml doesn't exercise the wheel build matrix.

Stack

Parent: #1867 (PR 3). Child: #1869 (PR 5).

The crate uses no nightly features, so the cibuildwheel overrides that
install nightly via rustup were wasted CI time and a churn source.
Pin stable + rustfmt + clippy via a rust-toolchain.toml at the repo
root; rustup picks it up automatically on the first cargo invocation
and installs the listed cross-compile targets too.

The macOS and Windows runners ship with rustup preinstalled, so their
before-build blocks collapse to `rustup show` (which still triggers
toolchain-file resolution and logs the resolved channel/targets for
the build record). Linux runners use the manylinux container which has
no rust at all, so they install rustup with --default-toolchain=none
and let the toolchain file pick the channel.

Drops CARGO_NET_GIT_FETCH_WITH_CLI from the Linux env block; it was a
setuptools-rust-era workaround that the maturin build no longer needs.
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.

1 participant