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

New resolver no deps extras install self #8678

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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