Skip to content

ci: add required-features entries to Cargo.toml#6031

Merged
davidhewitt merged 1 commit into
PyO3:mainfrom
davidhewitt:required-features
May 11, 2026
Merged

ci: add required-features entries to Cargo.toml#6031
davidhewitt merged 1 commit into
PyO3:mainfrom
davidhewitt:required-features

Conversation

@davidhewitt
Copy link
Copy Markdown
Member

This is a bit of an experiment to skip building tests when the feature combinations being run (typically --no-default-features) don't satisfy the cfgs at the top of the test files.

We have historically just made these test bodies empty with a #![cfg(feature = "...")] directive at the top of test files. I think these are good for clarity purposes; they're close to the code and can easily be updated if things change.

By adding these tests to required-features in Cargo.toml we can avoid producing useless test binaries. I would prefer to keep the cfg clauses around, so I wrote a nox job to lint that the cfgs match the Cargo.toml.

Open to opinions whether this is too much, and I should just drop this patch or remove the cfg markers.

@davidhewitt
Copy link
Copy Markdown
Member Author

This looks like it had some noticeable improvement to macos jobs (maybe ~2 mins), a small effect on windows jobs (maybe ~30s), and no noticeable effect on ubuntu jobs.

Could be due to different filesystem / kernel characteristics, I suppose?

I think given that there are some small wins and the test output is a fair bit cleaner with this (no "ran 0 tests" lines), I'm inclined to merge this, what do others think?

@davidhewitt davidhewitt marked this pull request as ready for review May 11, 2026 11:09
Copy link
Copy Markdown
Member

@bschoenmaeckers bschoenmaeckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@alex
Copy link
Copy Markdown
Member

alex commented May 11, 2026 via email

@davidhewitt davidhewitt added this pull request to the merge queue May 11, 2026
Merged via the queue into PyO3:main with commit 58d5a1e May 11, 2026
46 checks passed
@davidhewitt davidhewitt deleted the required-features branch May 11, 2026 12:12
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.

3 participants