From 3d7dee1208f1b75366e8788af9f8a7341f2ea866 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Sat, 19 Nov 2016 16:58:40 -0600 Subject: [PATCH] allow for rc in version values --- lbrynet/core/utils.py | 8 +++----- tests/unit/core/test_utils.py | 3 +++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lbrynet/core/utils.py b/lbrynet/core/utils.py index 598d6d793..08d5e813f 100644 --- a/lbrynet/core/utils.py +++ b/lbrynet/core/utils.py @@ -1,12 +1,13 @@ import base64 import datetime -import distutils.version import logging import random import os import socket import sys +import pkg_resources + from lbrynet.core.cryptoutils import get_lbry_hash_obj @@ -61,10 +62,7 @@ def is_valid_blobhash(blobhash): def version_is_greater_than(a, b): """Returns True if version a is more recent than version b""" - try: - return distutils.version.StrictVersion(a) > distutils.version.StrictVersion(b) - except ValueError: - return distutils.version.LooseVersion(a) > distutils.version.LooseVersion(b) + return pkg_resources.parse_version(a) > pkg_resources.parse_version(b) def deobfuscate(obfustacated): diff --git a/tests/unit/core/test_utils.py b/tests/unit/core/test_utils.py index 48f38c54b..b7eecea60 100644 --- a/tests/unit/core/test_utils.py +++ b/tests/unit/core/test_utils.py @@ -17,6 +17,9 @@ class CompareVersionTest(unittest.TestCase): def test_version_can_have_four_parts(self): self.assertTrue(utils.version_is_greater_than('1.3.9.1', '1.3.9')) + def test_release_is_greater_than_rc(self): + self.assertTrue(utils.version_is_greater_than('1.3.9', '1.3.9rc0')) + class ObfuscationTest(unittest.TestCase): def test_deobfuscation_reverses_obfuscation(self):