mirror of https://github.com/pypa/pip
Ask candidates for dependencies even on --no-deps
ExtrasCandidate need to provide one dependency on the non-extra-ed self.
This commit is contained in:
parent
b4632d080b
commit
3ce63a62d7
|
@ -69,8 +69,8 @@ class Candidate(object):
|
|||
# type: () -> Optional[Link]
|
||||
raise NotImplementedError("Override in subclass")
|
||||
|
||||
def iter_dependencies(self):
|
||||
# type: () -> Iterable[Optional[Requirement]]
|
||||
def iter_dependencies(self, ignore_dependencies):
|
||||
# type: (bool) -> Iterable[Optional[Requirement]]
|
||||
raise NotImplementedError("Override in subclass")
|
||||
|
||||
def get_install_requirement(self):
|
||||
|
|
|
@ -275,8 +275,10 @@ class _InstallRequirementBackedCandidate(Candidate):
|
|||
return None
|
||||
return spec
|
||||
|
||||
def iter_dependencies(self):
|
||||
# type: () -> Iterable[Optional[Requirement]]
|
||||
def iter_dependencies(self, ignore_dependencies):
|
||||
# type: (bool) -> Iterable[Optional[Requirement]]
|
||||
if ignore_dependencies:
|
||||
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(
|
||||
|
@ -420,8 +422,10 @@ class AlreadyInstalledCandidate(Candidate):
|
|||
# type: () -> str
|
||||
return "{} {} (Installed)".format(self.name, self.version)
|
||||
|
||||
def iter_dependencies(self):
|
||||
# type: () -> Iterable[Optional[Requirement]]
|
||||
def iter_dependencies(self, ignore_dependencies):
|
||||
# type: (bool) -> Iterable[Optional[Requirement]]
|
||||
if ignore_dependencies:
|
||||
return
|
||||
for r in self.dist.requires():
|
||||
yield self._factory.make_requirement_from_spec(str(r), self._ireq)
|
||||
|
||||
|
@ -519,10 +523,16 @@ class ExtrasCandidate(Candidate):
|
|||
# type: () -> Optional[Link]
|
||||
return self.base.source_link
|
||||
|
||||
def iter_dependencies(self):
|
||||
# type: () -> Iterable[Optional[Requirement]]
|
||||
def iter_dependencies(self, ignore_dependencies):
|
||||
# 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 ignore_dependencies:
|
||||
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)
|
||||
|
@ -535,10 +545,6 @@ class ExtrasCandidate(Candidate):
|
|||
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,
|
||||
|
@ -585,8 +591,8 @@ class RequiresPythonCandidate(Candidate):
|
|||
# type: () -> str
|
||||
return "Python {}".format(self.version)
|
||||
|
||||
def iter_dependencies(self):
|
||||
# type: () -> Iterable[Optional[Requirement]]
|
||||
def iter_dependencies(self, ignore_dependencies):
|
||||
# type: (bool) -> Iterable[Optional[Requirement]]
|
||||
return ()
|
||||
|
||||
def get_install_requirement(self):
|
||||
|
|
|
@ -145,6 +145,8 @@ class PipProvider(AbstractProvider):
|
|||
|
||||
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]
|
||||
return [
|
||||
r
|
||||
for r in candidate.iter_dependencies(self._ignore_dependencies)
|
||||
if r is not None
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue