]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
allmydata/__init__.py, test_version.py: make version parsing understand '<=', with...
authordavid-sarah <david-sarah@jacaranda.org>
Mon, 15 Aug 2011 03:51:53 +0000 (20:51 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Mon, 15 Aug 2011 03:51:53 +0000 (20:51 -0700)
src/allmydata/__init__.py
src/allmydata/test/test_version.py

index 439fb92514d20635152f19bf005baa82f0e51966..e57b5e6247e0e8a79372d4e4c8079b648bd2230d 100644 (file)
@@ -210,10 +210,10 @@ def get_package_versions_and_locations():
 
 def check_requirement(req, vers_and_locs):
     # TODO: check [] options
-    # We support only disjunctions of >= and ==
+    # We support only disjunctions of <=, >=, and ==
 
     reqlist = req.split(',')
-    name = reqlist[0].split('>=')[0].split('==')[0].strip(' ').split('[')[0]
+    name = reqlist[0].split('<=')[0].split('>=')[0].split('==')[0].strip(' ').split('[')[0]
     if name not in vers_and_locs:
         raise PackagingError("no version info for %s" % (name,))
     if req.strip(' ') == name:
@@ -227,19 +227,25 @@ def check_requirement(req, vers_and_locs):
     actualver = normalized_version(actual, what="actual version %r of %s from %r" % (actual, name, location))
 
     for r in reqlist:
-        s = r.split('>=')
+        s = r.split('<=')
         if len(s) == 2:
             required = s[1].strip(' ')
-            if actualver >= normalized_version(required, what="required minimum version %r in %r" % (required, req)):
-                return  # minimum requirement met
+            if actualver <= normalized_version(required, what="required maximum version %r in %r" % (required, req)):
+                return  # maximum requirement met
         else:
-            s = r.split('==')
+            s = r.split('>=')
             if len(s) == 2:
                 required = s[1].strip(' ')
-                if actualver == normalized_version(required, what="required exact version %r in %r" % (required, req)):
-                    return  # exact requirement met
+                if actualver >= normalized_version(required, what="required minimum version %r in %r" % (required, req)):
+                    return  # minimum requirement met
             else:
-                raise PackagingError("no version info or could not understand requirement %r" % (req,))
+                s = r.split('==')
+                if len(s) == 2:
+                    required = s[1].strip(' ')
+                    if actualver == normalized_version(required, what="required exact version %r in %r" % (required, req)):
+                        return  # exact requirement met
+                else:
+                    raise PackagingError("no version info or could not understand requirement %r" % (req,))
 
     msg = ("We require %s, but could only find version %s.\n" % (req, actual))
     if location and location != 'unknown':
index 1e7e3e34fa2231c68322160e24a849a4bde3a484..836e5965e5f97ed0dc35b53f91b744cca29d1cbf 100644 (file)
@@ -13,6 +13,8 @@ class CheckRequirement(unittest.TestCase):
         check_requirement("setuptools >= 0.6c6", {"setuptools": ("0.6", "", "distribute")})
         check_requirement("pycrypto == 2.0.1, == 2.1, >= 2.3", {"pycrypto": ("2.1.0", "", None)})
         check_requirement("pycrypto == 2.0.1, == 2.1, >= 2.3", {"pycrypto": ("2.4.0", "", None)})
+        check_requirement("zope.interface <= 3.6.2, >= 3.6.6", {"zope.interface": ("3.6.1", "", None)})
+        check_requirement("zope.interface <= 3.6.2, >= 3.6.6", {"zope.interface": ("3.6.6", "", None)})
 
         check_requirement("zope.interface", {"zope.interface": ("unknown", "", None)})
         check_requirement("mock", {"mock": ("0.6.0", "", None)})
@@ -30,6 +32,8 @@ class CheckRequirement(unittest.TestCase):
                               "foolscap[secure_connections] >= 0.6.0", {"foolscap": ("0.5.1", "", None)})
         self.failUnlessRaises(PackagingError, check_requirement,
                               "pycrypto == 2.0.1, == 2.1, >= 2.3", {"pycrypto": ("2.2.0", "", None)})
+        self.failUnlessRaises(PackagingError, check_requirement,
+                              "zope.interface <= 3.6.2, >= 3.6.6", {"zope.interface": ("3.6.4", "", None)})
         self.failUnlessRaises(PackagingError, check_requirement,
                               "foo >= 1.0", {})
         self.failUnlessRaises(PackagingError, check_requirement,