Skip to content

feat: stricter selector parsing, refactor to platforms module #2291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

joerick
Copy link
Contributor

@joerick joerick commented Feb 28, 2025

Implementation of an idea from #2070 (comment)

cibuildwheel will error out if the build config contains something that it doesn't recognise. For skip and test-skip, it just prints a warning.

This is to highlight misconfiguration as seen in #2070. Notably, the set of identifiers that cibuildwheel will consider is not dependent on platform, so users can still do a global CIBW_BUILD that's shared across platforms.

Also in this PR, I wanted to iterate through platform modules, and so decided it was time to factor them out into their own package.

I'll keep this draft to merge #2286 first, since that adds a new platform.

@joerick joerick force-pushed the selector-strict branch 3 times, most recently from f7c0412 to 6942c47 Compare February 28, 2025 20:19
@joerick
Copy link
Contributor Author

joerick commented Feb 28, 2025

This change made the unit tests quite a bit slower (26s), so I broke out the profiler. In doing so I spotted a few places things could be sped up. I'll split out the unrelated changes to a separate PR.

@henryiii
Copy link
Contributor

Do you know why this change made it slower, though?

@joerick
Copy link
Contributor Author

joerick commented Feb 28, 2025

Yeah, it was these lines, it ended up doing a lot of TOML loading and running of the BuildSelector.

@joerick
Copy link
Contributor Author

joerick commented Feb 28, 2025

I've kept only the optimisation relevant to this change, the rest are in #2293.

@henryiii
Copy link
Contributor

Can be rebased now.

joerick added 2 commits March 24, 2025 09:21
- Use a different method to build nothing
- Make the check aware of enable groups
@joerick joerick marked this pull request as ready for review March 24, 2025 10:05
def build(self, options: Options, tmp_path: Path) -> None: ...


ALL_PLATFORM_MODULES: Final[dict[PlatformName, PlatformModule]] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires all platforms be imported no matter what platform you are targeting, but I guess since get_python_configurations is now needed from every platform, that's fine.

from cibuildwheel.typing import GenericPythonConfiguration, PlatformName


class PlatformModule(Protocol):
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in this PR, but I think this will be a good structure to build on in the future; we could have several required methods. Now that we have gone from 3 backends to 5 (soon 6), more structure is good and Protocols are a good way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, this module type is working well - mypy caught that the ios module was missing the new all_python_configurations function after the rebase.

@joerick joerick merged commit 141e702 into main Mar 24, 2025
24 checks passed
@joerick joerick deleted the selector-strict branch March 24, 2025 16:58
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