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:
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':
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)})
"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,