Fix pex3 venv create --link-python for --pex-repository. - #3286
Merged
jsirois merged 4 commits intoSep 18, 2026
Merged
Conversation
Populating a venv's sources re-resolved the repository PEX, and that resolve
runs against a local interpreter. For a venv laid out for a foreign platform
the PEX need hold no distribution that interpreter can use, so a PEX built for
the foreign platform alone failed with e.g.:
A distribution for psutil could not be resolved for <local python>.
`_install_from_pex` has already resolved the distributions for the target, so
pass those down to the venv's `pex-repl` script instead of re-resolving. The
`PEX_TOOLS=1 ... venv` path keeps re-resolving, where the PEX and the
interpreter always agree.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012imZdyz1fhVXRNKPjbhSDw
The resulting yolo build using the local interpreter netted native wheels not compatible with the foreign platform.
Member
Author
|
Supercedes #3285. |
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.
pex3 venv create --link-pythonfor a foreign platform fails when the venv is installed from a--pex-repository:The distributions themselves install fine — it is populating the venv's sources that fails.
_populate_first_partyre-resolves the repository PEX to build thepex-replscript'sactivated_dists, and that resolve runs against a local interpreter, which a PEX built for the foreign platform alone holds nothing for._install_from_pexhas already resolved the distributions for the target, so this passes those down instead; thePEX_TOOLS=1 ... venvpath keeps re-resolving, where the PEX and the interpreter always agree.This is the combination Pants uses — it always invokes
pex3 venv createwith--pex-repository— so #3279 is unreachable from Pants without it.Repro and verification, on a linux aarch64 host:
Before: the error above. After:
bin/python,bin/python3andbin/python3.13all link to/opt/python/bin/bob, andlib/python3.13/site-packages/psutil/_psutil_linux.abi3.soisELF 64-bit LSB shared object, x86-64.test_foreign_target_link_python_from_pex_repositorycovers it. I could not run it locally — thepy310fixture's CPython 3.10.7 build fails in my environment (ensurepipexits non-zero) — so CI is its first run; the commands above are the same shape by hand.uv run dev-cmd format lint typecheckis green.Written with Claude Code, as was #3279.
🤖 Generated with Claude Code
https://claude.ai/code/session_012imZdyz1fhVXRNKPjbhSDw