Skip to content

Commit

Permalink
Merge pull request #8678 from uranusjr/new-resolver-no-deps-extras-in…
Browse files Browse the repository at this point in the history
…stall-self
  • Loading branch information
pradyunsg committed Aug 4, 2020
1 parent 4a39344 commit 552b837
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
2 changes: 2 additions & 0 deletions news/8677.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
New resolver: Correctly include the base package when specified with extras
in ``--no-deps`` mode.
4 changes: 2 additions & 2 deletions src/pip/_internal/resolution/resolvelib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def source_link(self):
# type: () -> Optional[Link]
raise NotImplementedError("Override in subclass")

def iter_dependencies(self):
# type: () -> Iterable[Optional[Requirement]]
def iter_dependencies(self, with_requires):
# type: (bool) -> Iterable[Optional[Requirement]]
raise NotImplementedError("Override in subclass")

def get_install_requirement(self):
Expand Down
30 changes: 18 additions & 12 deletions src/pip/_internal/resolution/resolvelib/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ def _get_requires_python_specifier(self):
return None
return spec

def iter_dependencies(self):
# type: () -> Iterable[Optional[Requirement]]
def iter_dependencies(self, with_requires):
# type: (bool) -> Iterable[Optional[Requirement]]
if not with_requires:
return
for r in self.dist.requires():
yield self._factory.make_requirement_from_spec(str(r), self._ireq)
python_dep = self._factory.make_requires_python_requirement(
Expand Down Expand Up @@ -420,8 +422,10 @@ def format_for_error(self):
# type: () -> str
return "{} {} (Installed)".format(self.name, self.version)

def iter_dependencies(self):
# type: () -> Iterable[Optional[Requirement]]
def iter_dependencies(self, with_requires):
# type: (bool) -> Iterable[Optional[Requirement]]
if not with_requires:
return
for r in self.dist.requires():
yield self._factory.make_requirement_from_spec(str(r), self._ireq)

Expand Down Expand Up @@ -519,10 +523,16 @@ def source_link(self):
# type: () -> Optional[Link]
return self.base.source_link

def iter_dependencies(self):
# type: () -> Iterable[Optional[Requirement]]
def iter_dependencies(self, with_requires):
# type: (bool) -> Iterable[Optional[Requirement]]
factory = self.base._factory

# Add a dependency on the exact base
# (See note 2b in the class docstring)
yield factory.make_requirement_from_candidate(self.base)
if not with_requires:
return

# The user may have specified extras that the candidate doesn't
# support. We ignore any unsupported extras here.
valid_extras = self.extras.intersection(self.base.dist.extras)
Expand All @@ -535,10 +545,6 @@ def iter_dependencies(self):
extra
)

# Add a dependency on the exact base
# (See note 2b in the class docstring)
yield factory.make_requirement_from_candidate(self.base)

for r in self.base.dist.requires(valid_extras):
requirement = factory.make_requirement_from_spec(
str(r), self.base._ireq, valid_extras,
Expand Down Expand Up @@ -585,8 +591,8 @@ def format_for_error(self):
# type: () -> str
return "Python {}".format(self.version)

def iter_dependencies(self):
# type: () -> Iterable[Optional[Requirement]]
def iter_dependencies(self, with_requires):
# type: (bool) -> Iterable[Optional[Requirement]]
return ()

def get_install_requirement(self):
Expand Down
9 changes: 6 additions & 3 deletions src/pip/_internal/resolution/resolvelib/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def is_satisfied_by(self, requirement, candidate):

def get_dependencies(self, candidate):
# type: (Candidate) -> Sequence[Requirement]
if self._ignore_dependencies:
return []
return [r for r in candidate.iter_dependencies() if r is not None]
with_requires = not self._ignore_dependencies
return [
r
for r in candidate.iter_dependencies(with_requires)
if r is not None
]
7 changes: 7 additions & 0 deletions tests/yaml/extras.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ cases:
- E 1.0.0
- F 1.0.0
skip: old
-
request:
- install: D[extra_1]
options: --no-deps
response:
- state:
- D 1.0.0

0 comments on commit 552b837

Please sign in to comment.