Commit 4ae1def3 by Sébastien Eustace

Fix handling of dependencies with a not in marker operator

parent 0faa0133
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
### Fixed ### Fixed
- Fixed installation of directory dependencies. - Fixed installation of directory dependencies.
- Fixed handling of dependencies with a `not in` marker operator.
## [0.12.5] - 2018-10-26 ## [0.12.5] - 2018-10-26
......
...@@ -105,20 +105,21 @@ def dependency_from_pep_508(name): ...@@ -105,20 +105,21 @@ def dependency_from_pep_508(name):
op = "" op = ""
elif op == "!=": elif op == "!=":
version += ".*" version += ".*"
elif op == "in": elif op in ("in", "not in"):
versions = [] versions = []
for v in re.split("[ ,]+", version): for v in re.split("[ ,]+", version):
split = v.split(".") split = v.split(".")
if len(split) in [1, 2]: if len(split) in [1, 2]:
split.append("*") split.append("*")
op = "" op_ = "" if op == "in" else "!="
else: else:
op = "==" op_ = "==" if op == "in" else "!="
versions.append(op + ".".join(split)) versions.append(op_ + ".".join(split))
glue = " || " if op == "in" else ", "
if versions: if versions:
ands.append(" || ".join(versions)) ands.append(glue.join(versions))
continue continue
......
...@@ -152,3 +152,20 @@ def test_dependency_from_pep_508_with_python_version_union_of_multi(): ...@@ -152,3 +152,20 @@ def test_dependency_from_pep_508_with_python_version_union_of_multi():
'python_version >= "2.7" and python_version < "2.8" ' 'python_version >= "2.7" and python_version < "2.8" '
'or python_version >= "3.4" and python_version < "3.5"' 'or python_version >= "3.4" and python_version < "3.5"'
) )
def test_dependency_from_pep_508_with_not_in_op_marker():
name = (
"jinja2 (>=2.7,<2.8)"
'; python_version not in "3.0,3.1,3.2" and extra == "export"'
)
dep = dependency_from_pep_508(name)
assert dep.name == "jinja2"
assert str(dep.constraint) == ">=2.7,<2.8"
assert dep.in_extras == ["export"]
assert dep.python_versions == "!=3.0.*, !=3.1.*, !=3.2.*"
assert (
str(dep.marker) == 'python_version not in "3.0,3.1,3.2" and extra == "export"'
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment