-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Set _PYTHON_HOST_PLATFORM when building wheels in CI #21942
Conversation
# macosx-10.9-universal2. Thus, without this env var, we tag our single-platform wheels | ||
# as universal2... this is a lie and understandably leads to installing the wrong wheel | ||
# and thus things do not work (see #21938 for an example). | ||
ret["_PYTHON_HOST_PLATFORM"] = "macosx-13.0-x86_64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also have logic in the GHA workflow to check that the wheel's filename is as expected? I.e. that no universal2
wheels were generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah, I'll add some extra checks to release.py
Woohoo. This looks better. From the CI logs:
Compared to a problematic build (e.g. the 2.26.0.dev0 release):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay! Thanks for fixing
I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants. ✔️ 2.25.xSuccessfully opened #21944. Thanks again for your contributions! |
…21942) (#21944) This follows the lead of `cibuildwheel` to explicitly correctly tag our wheels on macOS, via the `_PYTHON_HOST_PLATFORM` environment variable. This change ensures that the `pip` understands which platform each wheel is built for and compatible with, and thus external plugins using `pants_requirements(...)` work again. It appears the file name (including platform) tags of a wheel are derived from `sysconfig.get_platform()`, i.e. based on the build configuration of the current Python interpreter. Pants builds single platform wheels, so the wheels need to be tagged with the right CPU architecture. In #21655, we changed from tagging correctly to tagging incorrectly: - Before that change, our self-hosted runners had 'simple' Python interpreters, built for the current platform via Pyenv. `python -c 'import sysconfig; print(sysconfig.get_platform())' reports `macosx-10.15-x86_64` and `macosx-11.6-arm64`, and indeed the wheels were tagged like that. - After that change, we started using Python interpreters provided by GitHub-hosted runners. The interpreters report `macosx-10.9-universal2` on both the ARM64 and x86-64 runners. That is, they're built as universal binaries that can run on either architecture. This lead to the wheels being tagged as `universal2` as well. The `_PYTHON_HOST_PLATFORM` environment variable overrides the default `sysconfig.get_platform()` value, and appears to be designed for this sort of purpose (and is used by `cibuildwheel` for such): - https://github.com/python/cpython/blob/5505b91a684b0fc7ffcb3a5b325302671d74fb15/Lib/sysconfig.py#L652-L654 - https://github.com/pypa/cibuildwheel/blob/3805787fe7a0476391541d834fa548a721f0ab2e/cibuildwheel/macos.py#L318-L331 Fixes #21938 Co-authored-by: Huon Wilson <huon@exoflare.io>
This follows the lead of
cibuildwheel
to explicitly correctly tag our wheels on macOS, via the_PYTHON_HOST_PLATFORM
environment variable. This change ensures that thepip
understands which platform each wheel is built for and compatible with, and thus external plugins usingpants_requirements(...)
work again.It appears the file name (including platform) tags of a wheel are derived from
sysconfig.get_platform()
, i.e. based on the build configuration of the current Python interpreter. Pants builds single platform wheels, so the wheels need to be tagged with the right CPU architecture.In #21655, we changed from tagging correctly to tagging incorrectly:
python -c 'import sysconfig; print(sysconfig.get_platform())' reports
macosx-10.15-x86_64and
macosx-11.6-arm64`, and indeed the wheels were tagged like that.macosx-10.9-universal2
on both the ARM64 and x86-64 runners. That is, they're built as universal binaries that can run on either architecture. This lead to the wheels being tagged asuniversal2
as well.The
_PYTHON_HOST_PLATFORM
environment variable overrides the defaultsysconfig.get_platform()
value, and appears to be designed for this sort of purpose (and is used bycibuildwheel
for such):Fixes #21938