feat(pex): use exec interpreter for PEX builds, enabling cross-builds#880
Merged
feat(pex): use exec interpreter for PEX builds, enabling cross-builds#880
Conversation
|
c9bedf3 to
4d47d05
Compare
whl_install's compile_pyc uses `py_toolchain.interpreter` which is resolved in target configuration. In cross-arch builds, the target interpreter is not runnable on the build host. Add a `resolved_py_toolchain` rule (analogous to `resolved_unpack_toolchain`) that re-exports the Python toolchain, and reference it via `cfg="exec"` so compileall gets a host-runnable interpreter. This is safe because .pyc bytecode depends on Python version, not architecture. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4d47d05 to
5820ab8
Compare
…#618) The PEX builder was being passed the target platform's interpreter, which fails in cross-builds (e.g. building a Linux PEX on macOS) with "Exec format error". Since rules_py already controls dependency resolution hermetically, the PEX builder doesn't need the target interpreter — it just needs to run on the build host. Remove the --python flag from py_pex_binary and let PEXBuilder use the current (cfg=exec) interpreter instead. Based on the work by Peter Lobsinger in #618. Co-Authored-By: Peter Lobsinger <peter@tecton.ai> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5820ab8 to
e4b49b5
Compare
arrdem
added a commit
that referenced
this pull request
Mar 20, 2026
…#881) When `compile_pyc` is enabled, `whl_install` invokes `compileall` using `py_toolchain.interpreter` which is resolved in **target** configuration. In cross-arch builds (e.g. x86 host building for arm64), the target interpreter isn't runnable on the build host, causing the action to fail. This adds a `resolved_py_toolchain` rule (following the existing `resolved_unpack_toolchain` pattern) and references it via `cfg="exec"` so compileall gets a host-runnable interpreter. This is safe because `.pyc` bytecode depends on Python version, not architecture. ### Changes are visible to end-users: no ### Test plan - Covered by existing test cases - Cross-arch scenario validated in #880 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Base automatically changed from
arrdem/whl-install-exec-python-compileall
to
main
March 20, 2026 07:44
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.

Takes over #618. The PEX builder previously required a target-configured Python interpreter, which fails in cross-arch builds since the target interpreter isn't runnable on the build host.
The fix removes the
--pythonargument entirely —PEXBuilder(interpreter=None)works because rules_py already controls dependency resolution hermetically; PEX doesn't need to probe the interpreter for platform compatibility.Also adds cross-arch
build_testtargets validating PEX builds for bothlinux_arm64andlinux_amd64viaplatform_transition_filegroup.Closes #618.
Changes are visible to end-users: yes
py_pex_binarynow supports cross-architecture builds (e.g. building an arm64 PEX on an x86 host).Test plan
build_testtargets addedpy-pex-binarye2e tests pass🤖 Generated with Claude Code