[internal] Refactor how call sites interact with Python resolves #14287
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.
The first change bundles
ResolveField.validate()
and.value_or_default()
, which makes call sites much less clunky.Note that this contrasts with JVM where we use
JvmSubsystem.resolves_for_target()
- I stuck withField
-based methods because it gives us better MyPy typing betweenResolveField
vsCompatibleResolveFields
.--
The second change prepares for how we will calculate the resolve to use. Before, we had call sites like
pytest_runner.py
setting the resolve. Instead,pex_from_targets.py
should choose the resolve based on the direct input addresses to the request. Then it validates that the transitive closure is correct. This implies:test
,package
, andrun
are chosen by simply inspecting the singlepython_test
orpex_binary
target, but validating all depsPexFromTargets
are all compatiblerepl
, we can't do any partitioning, only validationFor now, we simply use the default resolve. A followup will implement this algorithm, similar to our JVM code in
coursier_fetch.py
.Note that this means
--enable-resolves
now gives you roughly the same behavior as[python].experimental_lockfile
! That is, for now, we only support a single resolve, whatever is set by[python].default_resolve
. This means that we can remove[python].experimental_lockfile
andgenerate-user-lockfile
to simplify this code.