Skip to content

fix(whl_install): use exec-configured interpreter for pyc compilation#881

Merged
arrdem merged 1 commit intomainfrom
arrdem/whl-install-exec-python-compileall
Mar 20, 2026
Merged

fix(whl_install): use exec-configured interpreter for pyc compilation#881
arrdem merged 1 commit intomainfrom
arrdem/whl-install-exec-python-compileall

Conversation

@arrdem
Copy link
Collaborator

@arrdem arrdem commented Mar 20, 2026

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

🤖 Generated with Claude Code

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>
@aspect-workflows
Copy link

aspect-workflows bot commented Mar 20, 2026

Bazel 8 (Test)

All tests were cache hits

107 tests (100.0%) were fully cached saving 47s.


Bazel 9 (Test)

All tests were cache hits

107 tests (100.0%) were fully cached saving 1m 16s.


Bazel 8 (Test)

e2e

All tests were cache hits

41 tests (100.0%) were fully cached saving 33s.


Bazel 9 (Test)

e2e

All tests were cache hits

41 tests (100.0%) were fully cached saving 40s.


Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 444ms.

@arrdem arrdem force-pushed the arrdem/whl-install-exec-python-compileall branch from 5820ab8 to 7965f5f Compare March 20, 2026 07:38
@arrdem arrdem merged commit 429bd6c into main Mar 20, 2026
4 of 6 checks passed
@arrdem arrdem deleted the arrdem/whl-install-exec-python-compileall branch March 20, 2026 07:44
arrdem added a commit that referenced this pull request Mar 20, 2026
…#880)

> **Stacked on #881** — merge that first.

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 `--python` argument 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_test` targets validating PEX builds for both
`linux_arm64` and `linux_amd64` via `platform_transition_filegroup`.

Closes #618.

### Changes are visible to end-users: yes

- Searched for relevant documentation and updated as needed: no
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes

`py_pex_binary` now supports cross-architecture builds (e.g. building an
arm64 PEX on an x86 host).

### Test plan

- New cross-arch `build_test` targets added
- Existing `py-pex-binary` e2e tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Lobsinger <peter@tecton.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant