Skip to content

Commit

Permalink
Add requirements_to_install to RequirementSet
Browse files Browse the repository at this point in the history
This property is necessary because the
legacy resolver returns requirements that
need not be installed.
  • Loading branch information
sbidoul committed Jun 3, 2022
1 parent 0f6605e commit 86758b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@ def run(self, options: Values, args: List[str]) -> int:
if options.dry_run:
would_install_items = sorted(
(r.metadata["name"], r.metadata["version"])
# Use get_installation_order because it does some important
# filtering with the legacy resolver.
for r in resolver.get_installation_order(requirement_set)
for r in requirement_set.requirements_to_install
)
if would_install_items:
write_output(
Expand Down
13 changes: 13 additions & 0 deletions src/pip/_internal/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,16 @@ def get_requirement(self, name: str) -> InstallRequirement:
@property
def all_requirements(self) -> List[InstallRequirement]:
return self.unnamed_requirements + list(self.requirements.values())

@property
def requirements_to_install(self) -> List[InstallRequirement]:
"""Return the list of requirements that need to be installed.
TODO remove this property together with the legacy resolver, since the new
resolver only returns requirements that need to be installed.
"""
return [
install_req
for install_req in self.all_requirements
if not install_req.constraint and not install_req.satisfied_by
]

0 comments on commit 86758b5

Please sign in to comment.