Skip to content

Commit 701a5d6

Browse files
committed
Add requirements_to_install to RequirementSet
This property is necessary because the legacy resolver returns requirements that need not be installed.
1 parent f8a54ab commit 701a5d6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/pip/_internal/commands/install.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ def run(self, options: Values, args: List[str]) -> int:
356356
if options.dry_run:
357357
would_install_items = sorted(
358358
(r.metadata["name"], r.metadata["version"])
359-
# Use get_installation_order because it does some important
360-
# filtering with the legacy resolver.
361-
for r in resolver.get_installation_order(requirement_set)
359+
for r in requirement_set.requirements_to_install
362360
)
363361
if would_install_items:
364362
write_output(

src/pip/_internal/req/req_set.py

+13
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,16 @@ def get_requirement(self, name: str) -> InstallRequirement:
6767
@property
6868
def all_requirements(self) -> List[InstallRequirement]:
6969
return self.unnamed_requirements + list(self.requirements.values())
70+
71+
@property
72+
def requirements_to_install(self) -> List[InstallRequirement]:
73+
"""Return the list of requirements that need to be installed.
74+
75+
TODO remove this property together with the legacy resolver, since the new
76+
resolver only returns requirements that need to be installed.
77+
"""
78+
return [
79+
install_req
80+
for install_req in self.all_requirements
81+
if not install_req.constraint and not install_req.satisfied_by
82+
]

0 commit comments

Comments
 (0)