Skip to content

Conversation

@konstin
Copy link
Member

@konstin konstin commented Sep 30, 2025

Error when a built wheel is for the wrong platform. This can happen especially when using --python-platform or --python-version with uv pip install.

Fixes #16019

@konstin konstin added the bug Something isn't working label Sep 30, 2025
@konstin konstin temporarily deployed to uv-test-registries September 30, 2025 12:46 — with GitHub Actions Inactive
@konstin konstin force-pushed the konsti/check-built-wheel-tags branch from 5e38b44 to 2e54e1f Compare October 8, 2025 07:12
@konstin konstin temporarily deployed to uv-test-registries October 8, 2025 07:15 — with GitHub Actions Inactive
@konstin konstin marked this pull request as ready for review October 8, 2025 08:14
@konstin
Copy link
Member Author

konstin commented Oct 8, 2025

There are no changes in the ecosystem tests, so this is ready to be reviewed and merged.

@konstin konstin force-pushed the konsti/check-built-wheel-tags branch from 2e54e1f to b089410 Compare October 16, 2025 20:54
@konstin konstin requested a review from zanieb October 16, 2025 20:56
@konstin konstin temporarily deployed to uv-test-registries October 16, 2025 20:56 — with GitHub Actions Inactive
@konstin konstin force-pushed the konsti/check-built-wheel-tags branch from b089410 to da3d2c9 Compare October 27, 2025 10:51
@konstin konstin temporarily deployed to uv-test-registries October 27, 2025 10:54 — with GitHub Actions Inactive
@konstin konstin force-pushed the konsti/check-built-wheel-tags branch from da3d2c9 to c660908 Compare December 2, 2025 15:14
@konstin konstin temporarily deployed to uv-test-registries December 2, 2025 15:17 — with GitHub Actions Inactive
@zanieb
Copy link
Member

zanieb commented Dec 3, 2025

Is it possible that this can cause false positives or regressions?

What if we're just building the wheel for a resolve (i.e., uv pip compile) and don't care if it's not valid?

@konstin
Copy link
Member Author

konstin commented Dec 3, 2025

Is it possible that this can cause false positives or regressions?

What if we're just building the wheel for a resolve (i.e., uv pip compile) and don't care if it's not valid?

It's technically possible but for this too happen, we need to have a case where:

  1. There is no static metadata
  2. The build backend doesn't support prepare_metadata_for_build_wheel
  3. The build backend always targets a specific platform
  4. The user is running uv pip compile on a non-target platform. This excludes cases with uv pip compile -p pointing to a target Python that can be emulated on the host.

Of these, (3) is very unlikely, in my experience build backends only have limited cross-compiling support if any, and I've never seen one that defaults to a different platform than the current one. It would also be strange to me if a build backend wouldn't implement prepare_metadata_for_build_wheel, as the functionality is a subset of the build_wheel hook.

--python-platform is a bit fragile by design (PEP 517 has no concept of a target that can be given to build backends, you can only pass them a real Python interpreter as sys.executable), but I'm not aware of other cases where this would cause a regression.

@konstin konstin temporarily deployed to uv-test-registries December 3, 2025 13:44 — with GitHub Actions Inactive
@konstin konstin temporarily deployed to uv-test-publish December 3, 2025 13:45 — with GitHub Actions Inactive
@zanieb
Copy link
Member

zanieb commented Dec 3, 2025

I'm wary because I think uv pip compile --python-platform is far more common than uv pip install --python-platform and I think this error can only cause regressions in the former / is only helpful for the latter.

What do you mean by (3)? Yes I would only expect most build backends to target the current platform and have no conception of cross-builds. Why would "always targets a specific platform" be needed for this to cause a regression?

@konstin konstin temporarily deployed to uv-test-registries December 3, 2025 15:28 — with GitHub Actions Inactive
@konstin konstin temporarily deployed to uv-test-publish December 3, 2025 15:28 — with GitHub Actions Inactive
konstin added a commit that referenced this pull request Dec 3, 2025
This was discovered by #16074

I'm not sure what the exact schema of the cache tag is, but since the project is dead, I don't expect any new non-matching versions to follow.
@konstin
Copy link
Member Author

konstin commented Dec 3, 2025

That's a very good point, I added a test specifically for this. The good news is it's already passing as the metadata-only branch in DistributionDatabase doesn't pass around tags nor does it check them.

The stronger checks uncovered a bug in how we generate tags for Pyston: #16972. Merging this PR may uncover more such problems on non-PyPI platform that usually don't have built wheels.

konstin added a commit that referenced this pull request Dec 4, 2025
This was discovered by #16074, where
the wrong tag now fails the Pyston integration test.

I'm not sure what the exact schema of the cache tag is, but since the
project is dead, I don't expect any new non-matching versions to follow.
Error when a built wheel is for the wrong platform. This can happen especially when using `--python-platform` or `--python-version` with `uv pip install`.

Fixes #16019

Ready for review but I want to make some more testing before merging.
@konstin konstin force-pushed the konsti/check-built-wheel-tags branch from 0bb042e to dfbb3ae Compare December 4, 2025 09:19
@konstin konstin temporarily deployed to uv-test-registries December 4, 2025 09:21 — with GitHub Actions Inactive
Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

I'd probably consider this an "enhancement" rather than a "bug"

@konstin konstin added enhancement New feature or improvement to existing functionality and removed bug Something isn't working labels Dec 5, 2025
@konstin konstin merged commit b73281d into main Dec 5, 2025
102 checks passed
@konstin konstin deleted the konsti/check-built-wheel-tags branch December 5, 2025 15:04
@mjamroz
Copy link

mjamroz commented Dec 9, 2025

guys is there any way to ignore that error? With this upgrade we cannot install kinto-11.2.1-cp3-none-any.whl on alpine anymore

@konstin
Copy link
Member Author

konstin commented Dec 9, 2025

@mjamroz Can you please file a new issue with a reproduction? cp3-none-any is a very odd tag, should it by py3-none-any?

@mjamroz
Copy link

mjamroz commented Dec 10, 2025

@konstin here you go #17061

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

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--python-platform can install source build for host instead of target

4 participants