summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-11-10 12:35:02 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-11-10 12:35:02 +0000
commita2438ec7a4191c177f0cb353fc92f2d8995e2803 (patch)
tree4045462d70b76101e0460ef0f6dcb2f9066e5354
parent8787ab96b01df209dd4bf72980c5fcfcb621534e (diff)
downloadimport-a2438ec7a4191c177f0cb353fc92f2d8995e2803.tar.gz
And now greater than
-rwxr-xr-xexts/pip_find_deps.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/exts/pip_find_deps.py b/exts/pip_find_deps.py
index 92237b7..18efb58 100755
--- a/exts/pip_find_deps.py
+++ b/exts/pip_find_deps.py
@@ -77,12 +77,22 @@ class Bound(object):
self.bound_type = bound_type
self.symbols = {'lower': ['<', '<='], 'upper': ['>', '>=']}
+ def val(self, x):
+ # type(self) should be Bound?
+ return x.value if isinstance(x, Bound) else x
+
# TODO: quite sure there's a much nicer way to be doing this sort of thing
# probably by defining __lt__, __eq__, __gt__ ourselves
+
+ # Note: x must be another Bound, we should enforce this somehow?
def __lt__(self, x):
+ print('__lt__ self: %s, x: %s' % (self, x))
+ x = self.val(x)
return x <= self.value if self.inclusive else x < self.value
def __gt__(self, x):
+ print('__gt__ self: %s, x: %s' % (self, x))
+ x = self.val(x)
return x >= self.value if self.inclusive else x > self.value
def _symbol(self):
@@ -130,7 +140,7 @@ class Dependency(object):
if not self._in_less_than(version):
return self.less_than.spec
elif not self._in_greater_than(version):
- return ('>', self.greater_than)
+ return self.greater_than.spec
else:
return None
@@ -160,7 +170,7 @@ def check_eqs(dep, version):
elif version > dep.less_than:
dep.conflicts.append((dep.less_than.spec, ('==', version)))
elif version < dep.greater_than:
- dep.conflicts.append((('>', dep.greater_than), ('==', version)))
+ dep.conflicts.append((dep.greater_than.spec, ('==', version)))
def check_lt(dep, version):
if dep.is_unconstrained():
@@ -169,7 +179,7 @@ def check_lt(dep, version):
if dep.absolute >= version:
dep.conflicts.append((('==', dep.absolute), ('<', version)))
elif dep.greater_than >= version:
- dep.conflicts.append((('>', dep.greater_than), ('<', version)))
+ dep.conflicts.append((dep.greater_than.spec, ('<', version)))
else:
dep.less_than = LowerBound(version, inclusive=False)
@@ -180,14 +190,14 @@ def check_lt_eq(dep, version):
def check_gt(dep, version):
if dep.is_unconstrained():
- dep.greater_than = version
+ dep.greater_than = UpperBound(version, inclusive=False)
elif dep.is_unbounded():
if dep.absolute <= version:
dep.conflicts.append((('==', dep.absolute), ('>', version)))
elif dep.less_than <= version:
dep.conflicts.append((dep.less_than.spec, ('>', version)))
else:
- dep.greater_than = version
+ dep.greater_than = UpperBound(version, inclusive=False)
def resolve_version_constraints(requirements):
build_deps = {}