mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Allow constraining an explicit requirement
This commit is contained in:
parent
9b3cd280fd
commit
d589795834
2 changed files with 9 additions and 8 deletions
|
@ -58,6 +58,13 @@ class Constraint(object):
|
||||||
hashes = self.hashes & other.hashes(trust_internet=False)
|
hashes = self.hashes & other.hashes(trust_internet=False)
|
||||||
return Constraint(specifier, hashes)
|
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):
|
class Requirement(object):
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -235,16 +235,10 @@ class Factory(object):
|
||||||
prefers_installed,
|
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 (
|
return (
|
||||||
c for c in explicit_candidates
|
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):
|
def make_requirement_from_install_req(self, ireq, requested_extras):
|
||||||
|
|
Loading…
Reference in a new issue