summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kowalik <steven@wedontsleep.org>2015-12-10 18:29:31 +1300
committerSteve Kowalik <steven@wedontsleep.org>2015-12-10 18:29:31 +1300
commitbca120fe59c78901914d837fd8dd9d0048196c87 (patch)
tree1409cf856ea2c9330be1175149bf30434269fe31
parent792edda4143317996f83ac5f1ae0db0695173397 (diff)
downloadpython-setuptools-git-bca120fe59c78901914d837fd8dd9d0048196c87.tar.gz
Update to the newest packaging, and collapse _parse_requirement_specs
-rw-r--r--pkg_resources/__init__.py5
-rw-r--r--pkg_resources/_vendor/packaging/requirements.py16
2 files changed, 10 insertions, 11 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index d463945f..d81430c7 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2873,10 +2873,7 @@ class RequirementParseError(ValueError):
def _parse_requirement_specs(req):
- if req.specifier:
- return [(spec.operator, spec.version) for spec in req.specifier]
- else:
- return []
+ return [(spec.operator, spec.version) for spec in req.specifier]
def parse_requirements(strs):
diff --git a/pkg_resources/_vendor/packaging/requirements.py b/pkg_resources/_vendor/packaging/requirements.py
index 95b2d986..dc3672e7 100644
--- a/pkg_resources/_vendor/packaging/requirements.py
+++ b/pkg_resources/_vendor/packaging/requirements.py
@@ -48,11 +48,13 @@ VERSION_PEP440 = Regex(Specifier._regex_str, re.VERBOSE | re.IGNORECASE)
VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE)
VERSION_ONE = VERSION_PEP440 | VERSION_LEGACY
-VERSION_MANY = VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE)
-VERSION_MANY.setParseAction(
- lambda s, l, t: SpecifierSet(','.join(t.asList()))
-)
-VERSION_SPEC = ((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY)("specifier")
+VERSION_MANY = Combine(VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE),
+ joinString=",")("_raw_spec")
+_VERSION_SPEC = Optional(((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY))
+_VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or '')
+
+VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier")
+VERSION_SPEC.setParseAction(lambda s, l, t: t[1])
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR.setParseAction(
@@ -61,7 +63,7 @@ MARKER_EXPR.setParseAction(
MARKER_SEPERATOR = SEMICOLON
MARKER = MARKER_SEPERATOR + MARKER_EXPR
-VERSION_AND_MARKER = Optional(VERSION_SPEC) + Optional(MARKER)
+VERSION_AND_MARKER = VERSION_SPEC + Optional(MARKER)
URL_AND_MARKER = URL + Optional(MARKER)
NAMED_REQUIREMENT = \
@@ -94,7 +96,7 @@ class Requirement(object):
else:
self.url = None
self.extras = req.extras.asList() if req.extras else []
- self.specifier = req.specifier if req.specifier else None
+ self.specifier = SpecifierSet(req.specifier)
self.marker = req.marker if req.marker else None
def __str__(self):