mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 15:16:41 +00:00
allmydata/__init__.py, test_version.py: make version parsing understand '<=', with test. refs #1435
This commit is contained in:
parent
16e6bb2b73
commit
a48aee11b3
@ -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':
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user