def check_version(actver, version, cmp_op): """ Check version string of an active module against a required version. If dev/prerelease tags result in TypeError for string-number comparison, it is assumed that the dependency is satisfied. Users on dev branches are responsible for keeping their own packages up to date. Copyright (C) 2013 The IPython Development Team Distributed under the terms of the BSD License. """ if isinstance(actver, tuple): actver = '.'.join([str(i) for i in actver]) # Hacks needed so that LooseVersion understands that (for example) # version = '3.0.0' is in fact bigger than actver = '3.0.0rc1' if is_stable_version(version) and not is_stable_version(actver) and \ actver.startswith(version) and version != actver: version = version + 'zz' elif is_stable_version(actver) and not is_stable_version(version) and \ version.startswith(actver) and version != actver: actver = actver + 'zz' try: if cmp_op == '>': return LooseVersion(actver) > LooseVersion(version) elif cmp_op == '>=': return LooseVersion(actver) >= LooseVersion(version) elif cmp_op == '=': return LooseVersion(actver) == LooseVersion(version) elif cmp_op == '<': return LooseVersion(actver) < LooseVersion(version) elif cmp_op == '<=': return LooseVersion(actver) <= LooseVersion(version) else: return False except TypeError: return True
def check_update_available(self): """Checks if there is an update available. It takes as parameters the current version of Spyder and a list of valid cleaned releases in chronological order. Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...] """ # Don't perform any check for development versions if 'dev' in self.version: return (False, latest_release) # Filter releases if is_stable_version(self.version): releases = [r for r in self.releases if is_stable_version(r)] else: releases = [ r for r in self.releases if not is_stable_version(r) or r in self.version ] latest_release = releases[-1] return (check_version(self.version, latest_release, '<'), latest_release)