Repository navigation
feat(pypi): support cross-compiling C/C++ sdists in py_sdist_wheel - #4591
Open
rsartor-cmd wants to merge 1 commit into
Open
rsartor-cmd wants to merge 1 commit into
rsartor-cmd wants to merge 1 commit into
Conversation
Currently, `py_sdist_wheel` refuses to build when the target platform differs from the host platform, preventing cross-compilation of C/C++ extensions from source distributions. This change wires the target CC and Python C-header toolchains into `py_sdist_wheel` and `sdist_wheel_builder.py` so C/C++ sdists can be cross-compiled inside Bazel build actions: * Extracts target CC/C++/AR tool paths, compile/link flags, static runtime libraries, target `SOABI`, and target `Python.h` include directories in `py_sdist_wheel`. * Absolutizes execroot-relative paths in compiler/linker flags, strips redacted date/time macros, prefers link-action `-resource-dir=`, and synthesizes target `_sysconfigdata` with target `INCLUDEPY`. * Generates `meson-cross.ini` for `meson-python` builds (including `longdouble_format` and a Zig `ar-no-thin` wrapper for `hermetic_cc_toolchain`), isolates `PKG_CONFIG_LIBDIR` for `mesonpy` builds so host `pkg-config` does not shadow hermetic Python headers, and exposes sibling `bin/` directories from classic `whl_library` build dependencies. * Adds unit tests for flag absolutization/sanitization in `tests/pypi/py_sdist_wheel/sdist_wheel_builder_test.py`. * Adds a standalone `examples/sdist_cross_compile/` workspace verifying native `x86_64` and `x86_64 -> aarch64` (`hermetic-llvm`) builds of setuptools C and `meson-python` C/C++17 sdists.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #4590 (
rsartor-cmd/consume-sdist-part-1-sdist-wheel).Currently,
py_sdist_wheelrefuses to build when the target platformdiffers from the host platform, preventing cross-compilation of C/C++
extensions from source distributions.
This change wires the target CC and Python C-header toolchains into
py_sdist_wheelandsdist_wheel_builder.pyso C/C++ sdists can becross-compiled inside Bazel build actions:
Extracts target CC/C++/AR tool paths, compile/link flags, static
runtime libraries, target
SOABI, and targetPython.hincludedirectories in
py_sdist_wheel.Absolutizes execroot-relative paths in compiler/linker flags, strips
redacted date/time macros, prefers link-action
-resource-dir=, andsynthesizes target
_sysconfigdatawith targetINCLUDEPY.Generates
meson-cross.iniformeson-pythonbuilds (includinglongdouble_formatand a Zigar-no-thinwrapper forhermetic_cc_toolchain), isolatesPKG_CONFIG_LIBDIRformesonpybuilds so host
pkg-configdoes not shadow hermetic Python headers,and exposes sibling
bin/directories from classicwhl_librarybuild dependencies.
Adds unit tests for flag absolutization/sanitization in
tests/pypi/py_sdist_wheel/sdist_wheel_builder_test.py.Adds a standalone
examples/sdist_cross_compile/workspace verifyingnative
x86_64andx86_64 -> aarch64(hermetic-llvm) builds ofsetuptools C and
meson-pythonC/C++17 sdists.