Make Resolver.resolve take a plain list of InstallRequirement
See original GitHub issueWhat’s the problem this feature will solve?
Currently pip’s resolver logic is spread between pip._internal.req.req_set.RequirementSet
and pip._internal.legacy_resolve.Resolver
, among other classes. Regardless of the approach taken for implementing the new resolver, simplifying the interface to the resolve
function will help us re-use more code before and after the call to resolve
without having to consider the legacy resolution logic currently in RequirementSet
.
Describe the solution you’d like
Several steps should let us get rid of RequirementSet
as an input to Resolver
:
- Globally configure and manage whether temporary directories should get deleted
- Switch all directories currently handled in
InstallRequirement.remove_temporary_source
to be globally managed and subject to the configuration from the previous step. RemoveInstallRequirement.remove_temporary_source
- Remove
RequirementSet.cleanup_files
since it only callsInstallRequirement.remove_temporary_source
- Construct a new
RequirementSet
inResolver.resolve
fromroot_reqs
and use that during resolution. Return the newRequirementSet
, which callers should use for the next step of processing instead of the inputRequirementSet
they were using previously. - Instead of passing a
RequirementSet
toResolver.resolve
, passreq_set.unnamed_requirements + list(req_set.requirements.values())
intoResolver.resolve
similar to what is currently calculated withinResolver.resolve
here.
After these steps, we should be able to fork RequirementSet
into one class for use with initial requirement parsing here (which could be eventually simplified to a plain list), and another class for use within Resolver
(which could potentially be inlined into Resolver itself).
Alternative Solutions
- Continue using
RequirementSet
as the interface toResolver.resolve
and suffer since much of its logic is closely tied to the current method of dependency resolution/preparation, which would conflict with any new resolver.
Additional context
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (14 by maintainers)
Top GitHub Comments
Update from the future: Turns out this is still needed because
RequirementSet
still conflates requirements incorrectly in various cases, and we need to reduce its usage even more for the new resolver to get what it needs.Issues impacted by this include:
add_requirement()
incorrectly conflates requirements with the same name, but different extras)add_requirement()
rejects “duplicated” requirements, even if they can be merged into one non-conflicting requirement)Agreed. Simplifying the interface is the main point.