Skip to content

pip: use universal wheels only if there are no others#525

Open
allisonkarlitskaya wants to merge 1 commit intoflatpak:masterfrom
allisonkarlitskaya:universal-only-if-only
Open

pip: use universal wheels only if there are no others#525
allisonkarlitskaya wants to merge 1 commit intoflatpak:masterfrom
allisonkarlitskaya:universal-only-if-only

Conversation

@allisonkarlitskaya
Copy link
Copy Markdown

If any wheel is universal (like py3-linux-any), we'll immediately short-circuit and take it in preference to a source package under the theory that it's probably all pure Python sourcecode in there anyway. This misses an important point, however: some packages (like websockets) have optimized arch-specific wheels with specific optimizations and also publish slower universal wheels as a fallback. Selecting the universal wheel in this case is probably a mistake.

Modify the check so we only take the universal wheel if there's no platform-specific one. What happens next is up to user preference: by default you'll end up building from the sdist, but you can also --prefer-wheels (possibly with --wheel-arches) to get the platform-specific wheels instead.

If any wheel is universal (like py3-linux-any), we'll immediately
short-circuit and take it in preference to a source package under the
theory that it's probably all pure Python sourcecode in there anyway.
This misses an important point, however: some packages (like websockets)
have optimized arch-specific wheels with specific optimizations and also
publish slower universal wheels as a fallback.  Selecting the universal
wheel in this case is probably a mistake.

Modify the check so we only take the universal wheel if there's no
platform-specific one.  What happens next is up to user preference: by
default you'll end up building from the sdist, but you can also
`--prefer-wheels` (possibly with `--wheel-arches`) to get the
platform-specific wheels instead.
@allisonkarlitskaya allisonkarlitskaya requested a review from a team as a code owner April 12, 2026 17:00
@github-actions github-actions bot added the pip label Apr 12, 2026
@allisonkarlitskaya
Copy link
Copy Markdown
Author

Probably @bbhtt wants to look at this (after a bunch of related work just landed)...

@bbhtt
Copy link
Copy Markdown
Collaborator

bbhtt commented Apr 13, 2026

I'd rather have this behind an argument --force-platform-wheels or --force-sdist or such. Universal wheels are better for compat and I don't think it is common to have optimised platform specific wheels.

Currently it will force people to use --prefer-wheels more often which is a bit annoying.

@allisonkarlitskaya
Copy link
Copy Markdown
Author

Can you point me at examples of projects that have both universal wheels and also platform specific ones for which the platform-specific versions don't offer some benefit (like improved performance)?

The very very fact that someone went to the trouble of having such an arrangement sort of suggests to me that there was a point in doing so, but I'm coming at this from the perspective in which I first encountered the issue and maybe there are others that I'm missing...

@allisonkarlitskaya
Copy link
Copy Markdown
Author

fwiw, I agree with your comments about universal wheels being "better for compat", which I interpret as "easier". Building an sdist is often a fraught process and it's not unlikely that it involves a build backend or compiler or some other tooling that won't be present in the chosen SDK... I did hesitate in proposing this because I feel like some people will get burned by this when their working builds suddenly stop working because some piece of tooling is missing...

But I'm still curious about your comments about the benefits of platform specific wheels (for the cases where they exist)...

@bbhtt
Copy link
Copy Markdown
Collaborator

bbhtt commented Apr 13, 2026

the platform-specific versions don't offer some benefit (like improved performance)?

I wouldn't know that without looking into every project individually and also things like this would depend on case by case basis if that code path is being used etc or if it matters in usage.

But having none-any and platform specific wheels is common enough. Quickly scanning the top 500 modules on PyPI gives 937 matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants