You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prune and verify architectures for rebuilt macOS wheels (#21692)
This is to prune unused architectures from the wheels we rebuild and
"repair" on macOS.
The primary driver is to enable `delocate_wheel`'s architecture
verification (`require_archs`) to ensure all bundled binaries and their
dependencies have matching architectures.
This brings additional benefits:
- the name of rebuilt/repaired wheels now accurately reflect their
content, (no foreign architecture in them)
- there's no longer a need for renaming repaired wheels, as their names
are now correctly set in the first place by the `pip` toolchain when
rebuilding,
- the size of each rebuilt wheel decreases by 10% to 50% - a modest but
welcome improvement that helps reduce the Agent's software
distribution costs.
Single-architecture builds are obtained by setting environment variables
in the `build_macos` function:
- `ARCHFLAGS='-arch <target_arch>'`: set effective build output
architecture (bundled binaries),
- `_PYTHON_HOST_PLATFORM=macosx-X.Y-<target_arch>`: set wheel platform
tag (used by the `pip` toolchain to set the wheel's name).
Together, they ensure both binaries and wheel metadata match the single
target architecture, with the former allowing `delocate_wheel` to verify
architecture consistency.
Why environment variables: there is no `--platform` flag for `pip wheel`
to control the build output architecture, because the proposed flag
(pypa/pip#5453) was never merged. Environment variables are the _de
facto_ standard approach used by `cibuildwheel`, `conda-forge` as well
as other wheel building tools.
References:
- pypa/pip#5453: proposal for `--platform` flag (not implemented),
- pypa/cibuildwheel#997: cross-compilation implementation,
- pypa/packaging#882: architecture tag control on macOS,
- https://cibuildwheel.pypa.io/en/stable/platforms/
0 commit comments