提交 d5897958 编写于 作者: T Tzu-ping Chung

Allow constraining an explicit requirement

上级 9b3cd280
......@@ -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):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册