Set _PYTHON_HOST_PLATFORM when building wheels in CI (Cherry-pick of #21942) #21944
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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