feat(pex): support cross builds of py_pex_binary targetting Linux #618
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.
Cross builds of bundled applications would be really nice to be able to do.
Often, we're bundling for the purposes of distributing an artifact, and in many cases
the ultimate execution targets for the distributed artifact do not necessarily match
the build machine.
The
PyPex
action itself can support cross-builds in a fairly straightforward way:use the
cfg="exec"
Python to run the PEX bundling code, rather than thecfg="target"
Python. The former is what this ruleset's PEX wrapper is alreadyrunning as, so all the must be done is to not request an alternative interpreter
when calling into the PEX library. Unfortunately, that's precisely what the tool
had been doing.
For instance, prior to this change, building an x86-64 Linux PEX binary on Macos
resulted in failures with diagnostics of the form:
The way
rules_py
is using PEX, changing the interpreter should not have othermeaningful effects. Perhaps if we were
allowing PEX to resolve requirements freely, changing the interpreter would change
the resolution results. However, that's non-hermetic, and the
rules_py
PEX wrapperalready explicitly controls what dependencies are used and where they come from.
Unfortunately, we are only able to support cross-builds targetting Linux at the current time
(and perhaps MacOS in release rulesets).
Other accidental complexity blocks targetting of other platforms.
See #625 for details.
However, even limited to just Linux as a cross target, the feature is valuable as Linux is very popular in
certain contexts.
Changes are visible to end-users: yes
Test plan