summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-11-11 13:53:12 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-11-11 13:53:12 +0000
commitce97654b73111f299b37cfa80c4cf3696abdf26c (patch)
tree2fd4f1e4d7e43f1b03108a654ce7bf4c1d7403e2
parente3fd4059a9a52605b0b6e6ac0894ac7d3edd3e0c (diff)
downloadimport-ce97654b73111f299b37cfa80c4cf3696abdf26c.tar.gz
fix conflict detection for <=
-rwxr-xr-xexts/pip_find_deps.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/exts/pip_find_deps.py b/exts/pip_find_deps.py
index f5f5715..bad31ec 100755
--- a/exts/pip_find_deps.py
+++ b/exts/pip_find_deps.py
@@ -182,26 +182,41 @@ def check_eqs(dep, version):
elif dep.greater_than > version:
dep.conflicts.append((dep.greater_than.spec, ('==', version)))
+# < x and == y: conflict, so conflict if y >= x
+# <= x and == y: no conflict, so conflict if y > x
def check_lt(dep, version, inclusive=False):
lt_symbol = '<=' if inclusive else '<'
+ lt = LowerBound(version, inclusive)
+
+ def abs_cmp(x, y):
+ return x > y if inclusive else x >= y
if dep.is_unconstrained():
dep.less_than = LowerBound(version, inclusive)
elif dep.is_unbounded():
- if dep.absolute >= version:
+ # if dep.absolute >= version: # unless inclusive!
+ # TODO: could probably use our existing bound thing for this
+ if abs_cmp(dep.absolute, version):
dep.conflicts.append((('==', dep.absolute), (lt_symbol, version)))
elif dep.greater_than >= version:
dep.conflicts.append((dep.greater_than.spec, (lt_symbol, version)))
else:
dep.less_than = LowerBound(version, inclusive)
+# > x and == y: conflict, so conflict if y <= x
+# >= x and == y: no conflict, so conflict if y < x
def check_gt(dep, version, inclusive=False):
gt_symbol = '>=' if inclusive else '>'
+ gt = UpperBound(version, inclusive)
+
+ def abs_cmp(x, y):
+ return x < y if inclusive else x <= y
if dep.is_unconstrained():
dep.greater_than = UpperBound(version, inclusive)
elif dep.is_unbounded():
- if dep.absolute <= version:
+ if dep.absolute <= version: # again unless inclusive
+ #if gt >= dep.absolute:
dep.conflicts.append((('==', dep.absolute), (gt_symbol, version)))
elif dep.less_than <= version:
dep.conflicts.append((dep.less_than.spec, (gt_symbol, version)))