Skip to content

Fix platform tag selection for wheels built with a build script - #1003

Open
officialpm wants to merge 4 commits into
python-poetry:mainfrom
officialpm:fix-11265-wheel-platform-tag
Open

officialpm wants to merge 4 commits into
python-poetry:mainfrom
officialpm:fix-11265-wheel-platform-tag

Conversation

@officialpm

@officialpm officialpm commented Nov 24, 2026 •

Copy link
Copy Markdown

Resolves: python-poetry/poetry#11265

Since packaging 26.3 (vendored in poetry-core 2.5.0), the native linux_* platform tag is listed before the more specific manylinux_*/musllinux_* tags in sys_tags() (pypa/packaging#160). Because WheelBuilder.tag simply picked the first tag, poetry build on a project with a build script now produces linux_x86_64 wheels instead of manylinux_* ones, and PyPI rejects those on upload.

This restores the previous tag selection by preferring the first tag that is more specific than the native linux_* tag, falling back to the first tag when no specific tag exists. Behavior on macOS and Windows is unchanged.

  • Added tests for changed code.
  • Updated documentation for changed code.

Add a static method to select the most specific platform tag for wheels, ensuring compatibility with previous tagging conventions.
Add parameterized test for selecting system tags based on packaging version.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/poetry/core/masonry/builders/wheel.py" line_range="447" />
<code_context>
+        (PyPI-compatible) platform tag.
+        """
+        return next(
+            (tag for tag in tags if not tag.rpartition("-")[2].startswith("linux_")),
+            tags[0],
+        )
</code_context>
<issue_to_address>
**Native wheels are advertised as universal**

When running on Linux without manylinux or musllinux tags, when `sys_tags()` includes generic `any` tags, `_select_sys_tag` skips native `linux_*` tags and selects a later `*-none-any` tag, so a build-script wheel containing native or architecture-specific outputs is labeled platform-independent and installers offer it on incompatible platforms.

Prefer a native Linux tag when no compatible manylinux or musllinux tag is available, rather than accepting a later `any` tag.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if the selection is wrong, the built wheel can carry a platform tag that blocks upload or makes installers treat it as compatible with the wrong systems. Wheels already distributed remain affected after a revert, but they can be yanked and rebuilt with the corrected tag.

Blocking findings: src/poetry/core/masonry/builders/wheel.py:447


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
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.

poetry build with build script produces generic platform wheels which are unable to be uploaded to PyPI (regression in poetry-core@2.5.0)

1 participant