Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying a named resolve as the superset in a PexRequirements. #18397

Merged
merged 2 commits into from Mar 3, 2023

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Mar 3, 2023

This named resolve must be a user resolve defined in [python].resolves.

This will allow us to move towards specifying a user resolve as the source to resolve a tool from. We can't use the existing LoadedLockfile superset for this, because we don't have access to the PythonSetup subsystem (which provides the list of resolves) when we construct the PexRequirements for a tool, so we don't know which lockfile the name corresponds to.

This named resolve must be a user resolve defined in
[python].resolves.

This will allow us to move towards specifying a user resolve
as the source to resolve a tool from.  We can't use the existing
LoadedLockfile superset for this, because we don't have access
to the PythonSetup subsystem (which provides the list of resolves)
when we construct the PexRequirements for a tool, so we don't
know which lockfile the name corresponds to.
@@ -433,26 +437,28 @@ async def _setup_pex_requirements(
pip_resolver_args = [*resolve_config.pex_args(), "--resolver-version", "pip-2020-resolver"]

if isinstance(request.requirements, EntireLockfile):
lockfile = await Get(LoadedLockfile, LoadedLockfileRequest(request.requirements.lockfile))
loaded_lockfile = await Get(
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rename is good for clarity, but was also necessary to avoid a mypy error, since we reuse this var name below.

# A named resolve for a "user lockfile".
# Soon to be the only kind of lockfile, as this class will help
# get rid of the "tool lockfile" concept.
name: str
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After we get rid of tool lockfiles we may be able to pare the lockfile-related types (Resolve, ChosenPythonResolve, Lockfile, LoadedLockfileRequest, LoadedLockfile, EntireLockfile) down substantially.

@@ -608,7 +619,7 @@ async def build_pex(
)


def _build_pex_description(request: PexRequest) -> str:
def _build_pex_description(request: PexRequest, resolve_to_lockfile: dict[str, str]) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _build_pex_description(request: PexRequest, resolve_to_lockfile: dict[str, str]) -> str:
def _build_pex_description(request: PexRequest, resolve_to_lockfile: Mapping[str, str]) -> str:

@benjyw benjyw merged commit 34d0157 into pantsbuild:main Mar 3, 2023
@benjyw benjyw deleted the resolve_in_pex_requirements branch March 3, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants