def check_requirement(req, vers_and_locs):
- # We support only conjunctions of <=, >=, and !=
+ # We support only conjunctions of <=, >=, ==, and !=
reqlist = req.split(',')
- name = reqlist[0].split('<=')[0].split('>=')[0].split('!=')[0].strip(' ').split('[')[0]
+ name = (reqlist[0].split('<=')[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:
def match_requirement(req, reqlist, actualver):
for r in reqlist:
- s = r.split('<=')
- if len(s) == 2:
- required = s[1].strip(' ')
- if not (actualver <= normalized_version(required, what="required maximum version %r in %r" % (required, req))):
- return False # maximum requirement not met
- else:
- s = r.split('>=')
+ for op, compare, desc in [('<=', lambda x, y: x <= y, "required maximum version"),
+ ('>=', lambda x, y: x >= y, "required minimum version"),
+ ('==', lambda x, y: x == y, "required exact version"),
+ ('!=', lambda x, y: x != y, "excluded version"),
+ (None, None, None)]:
+ if op is None:
+ raise PackagingError("no version info or could not understand requirement %r" % (req,))
+ s = r.split(op)
if len(s) == 2:
required = s[1].strip(' ')
- if not (actualver >= normalized_version(required, what="required minimum version %r in %r" % (required, req))):
- return False # minimum requirement not met
- else:
- s = r.split('!=')
- if len(s) == 2:
- required = s[1].strip(' ')
- if not (actualver != normalized_version(required, what="excluded version %r in %r" % (required, req))):
- return False # not-equal requirement not met
+ if not compare(actualver, normalized_version(required, what="%s %r in %r" % (desc, required, req))):
+ return False # requirement not met
else:
- raise PackagingError("no version info or could not understand requirement %r" % (req,))
+ break # next requirement from reqlist
return True
# under both the old and new semantics. That can be achieved by limiting
# requirement specs to one of the following forms:
#
+# * == X
# * >= X, <= Y where X < Y
# * >= X, != Y, != Z, ... where X < Y < Z...
#
# (In addition, check_requirement in allmydata/__init__.py only supports
-# >=, <= and != operators.)
+# >=, <=, ==, and != operators.)
install_requires = [
# We require newer versions of setuptools (actually
'mock',
'pyasn1',
'pyasn1-modules',
- 'python-gflags',
]
# Dependencies reported by pkg_resources that we can safely ignore.
'twisted-web',
'twisted-core',
'twisted-conch',
+ 'python-gflags',
+ 'httplib2',
]
import sys
self._check_success("pycrypto >= 2.1.0, != 2.2, != 2.4", {"pycrypto": ("2.4.1", "", None)})
self._check_success("Twisted >= 11.0.0, <= 12.2.0", {"Twisted": ("11.0.0", "", None)})
self._check_success("Twisted >= 11.0.0, <= 12.2.0", {"Twisted": ("12.2.0", "", None)})
+ self._check_success("oauth2client == 1.1.0", {"oauth2client": ("1.1.0", "", None)})
self._check_success("zope.interface", {"zope.interface": ("unknown", "", None)})
self._check_success("mock", {"mock": ("0.6.0", "", None)})
self._check_failure("pycrypto >= 2.1.0, != 2.2, != 2.4", {"pycrypto": ("2.0.0", "", None)})
self._check_failure("Twisted >= 11.0.0, <= 12.2.0", {"Twisted": ("10.2.0", "", None)})
self._check_failure("Twisted >= 11.0.0, <= 12.2.0", {"Twisted": ("13.0.0", "", None)})
+ self._check_failure("oauth2client == 1.1.0", {"oauth2client": ("1.0.0", "", None)})
self._check_failure("foo >= 1.0", {})
self._check_failure("foo >= 1.0", {"foo": ("irrational", "", None)})