mirror of https://github.com/pypa/pip
Allow constraining an explicit requirement
This commit is contained in:
parent
9b3cd280fd
commit
d589795834
|
@ -58,6 +58,13 @@ class Constraint(object):
|
|||
hashes = self.hashes & other.hashes(trust_internet=False)
|
||||
return Constraint(specifier, hashes)
|
||||
|
||||
def is_satisfied_by(self, candidate):
|
||||
# type: (Candidate) -> bool
|
||||
# We can safely always allow prereleases here since PackageFinder
|
||||
# already implements the prerelease logic, and would have filtered out
|
||||
# prerelease candidates if the user does not expect them.
|
||||
return self.specifier.contains(candidate.version, prereleases=True)
|
||||
|
||||
|
||||
class Requirement(object):
|
||||
@property
|
||||
|
|
|
@ -235,16 +235,10 @@ class Factory(object):
|
|||
prefers_installed,
|
||||
)
|
||||
|
||||
if constraint:
|
||||
name = explicit_candidates.pop().name
|
||||
raise InstallationError(
|
||||
"Could not satisfy constraints for {!r}: installation from "
|
||||
"path or url cannot be constrained to a version".format(name)
|
||||
)
|
||||
|
||||
return (
|
||||
c for c in explicit_candidates
|
||||
if all(req.is_satisfied_by(c) for req in requirements)
|
||||
if constraint.is_satisfied_by(c)
|
||||
and all(req.is_satisfied_by(c) for req in requirements)
|
||||
)
|
||||
|
||||
def make_requirement_from_install_req(self, ireq, requested_extras):
|
||||
|
|
Loading…
Reference in New Issue