From 5a1d4aa8b70e929672dad19c99d08c4888e5d940 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Thu, 16 Aug 2007 16:16:41 -0700 Subject: [PATCH] version_class.py: if you don't have pkg_resources for comparing version numbers, use distutils.version.LooseVersion --- src/allmydata/util/version_class.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/allmydata/util/version_class.py b/src/allmydata/util/version_class.py index dbab3b87..da6fe488 100644 --- a/src/allmydata/util/version_class.py +++ b/src/allmydata/util/version_class.py @@ -10,7 +10,15 @@ extended version number class """ # from setuptools, but intended to be included in future version of Python Standard Library (PEP 365) -import pkg_resources +try: + import pkg_resources +except ImportError: + import distutils.version + def cmp_version(v1, v2): + return cmp(distutils.version.LooseVersion(str(v1)), distutils.version.LooseVersion(str(v2))) +else: + def cmp_version(v1, v2): + return cmp(pkg_resources.parse_version(str(v1)), pkg_resources.parse_version(str(v2))) # bindann, by Nathan Wilcox (needed only for debugging) try: @@ -130,4 +138,4 @@ class Version(object): return self.__str__() def __cmp__ (self, other): - return cmp(pkg_resources.parse_version(str(self)), pkg_resources.parse_version(str(other))) + return cmp_version(self, other) -- 2.45.2