diff options
Diffstat (limited to 'third_party/python/setuptools/setuptools/_distutils/versionpredicate.py')
-rw-r--r-- | third_party/python/setuptools/setuptools/_distutils/versionpredicate.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/third_party/python/setuptools/setuptools/_distutils/versionpredicate.py b/third_party/python/setuptools/setuptools/_distutils/versionpredicate.py index 062c98f248..d6c0c007aa 100644 --- a/third_party/python/setuptools/setuptools/_distutils/versionpredicate.py +++ b/third_party/python/setuptools/setuptools/_distutils/versionpredicate.py @@ -1,15 +1,14 @@ """Module for parsing and testing package version predicate strings. """ import re -import distutils.version +from . import version import operator -re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)", - re.ASCII) +re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)", re.ASCII) # (package) (rest) -re_paren = re.compile(r"^\s*\((.*)\)\s*$") # (list) inside of parentheses +re_paren = re.compile(r"^\s*\((.*)\)\s*$") # (list) inside of parentheses re_splitComparison = re.compile(r"^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$") # (comp) (version) @@ -23,10 +22,20 @@ def splitUp(pred): if not res: raise ValueError("bad package restriction syntax: %r" % pred) comp, verStr = res.groups() - return (comp, distutils.version.StrictVersion(verStr)) + with version.suppress_known_deprecation(): + other = version.StrictVersion(verStr) + return (comp, other) + + +compmap = { + "<": operator.lt, + "<=": operator.le, + "==": operator.eq, + ">": operator.gt, + ">=": operator.ge, + "!=": operator.ne, +} -compmap = {"<": operator.lt, "<=": operator.le, "==": operator.eq, - ">": operator.gt, ">=": operator.ge, "!=": operator.ne} class VersionPredicate: """Parse and test package version predicates. @@ -94,8 +103,7 @@ class VersionPredicate: """ def __init__(self, versionPredicateStr): - """Parse a version predicate string. - """ + """Parse a version predicate string.""" # Fields: # name: package name # pred: list of (comparison string, StrictVersion) @@ -115,8 +123,7 @@ class VersionPredicate: str = match.groups()[0] self.pred = [splitUp(aPred) for aPred in str.split(",")] if not self.pred: - raise ValueError("empty parenthesized list in %r" - % versionPredicateStr) + raise ValueError("empty parenthesized list in %r" % versionPredicateStr) else: self.pred = [] @@ -140,6 +147,7 @@ class VersionPredicate: _provision_rx = None + def split_provision(value): """Return the name and optional version number of a provision. @@ -154,13 +162,14 @@ def split_provision(value): global _provision_rx if _provision_rx is None: _provision_rx = re.compile( - r"([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$", - re.ASCII) + r"([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$", re.ASCII + ) value = value.strip() m = _provision_rx.match(value) if not m: raise ValueError("illegal provides specification: %r" % value) ver = m.group(2) or None if ver: - ver = distutils.version.StrictVersion(ver) + with version.suppress_known_deprecation(): + ver = version.StrictVersion(ver) return m.group(1), ver |