From 107bfe25eb4a1674975d48ab4ab7e4ccbba5bbb5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 13 Mar 2024 12:14:03 +0200 Subject: [PATCH] Updated for pkg_resources --- slpkg/upgrade.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index e465f3be..61cd090a 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -3,7 +3,7 @@ import logging from typing import Generator -from packaging.version import parse, InvalidVersion +from pkg_resources import parse_version from slpkg.rules import Rules from slpkg.configs import Configs @@ -70,14 +70,14 @@ class Upgrade(Configs): installed_package: str = f'{name}-{inst_package_version}' try: - if parse(repository_package) > parse(installed_package): + if parse_version(repository_package) > parse_version(installed_package): return True - if (parse(repository_package) == parse(installed_package) - and parse(repo_package_build) > parse(inst_package_build)): + if (parse_version(repository_package) == parse_version(installed_package) + and parse_version(repo_package_build) > parse_version(inst_package_build)): return True - except InvalidVersion: + except ValueError: logger = logging.getLogger(LoggingConfig.date_time) logger.exception(f"{self.__class__.__name__}: " f"{self.__class__.is_package_upgradeable.__name__}: " @@ -85,10 +85,10 @@ class Upgrade(Configs): f"{repository_package=}, {installed_package=}, {repository_package > installed_package}, " f"{repository_package == installed_package and repo_package_build > inst_package_build}") - if repository_package > installed_package: - return True + if repository_package > installed_package: + return True - if repository_package == installed_package and repo_package_build > inst_package_build: - return True + if repository_package == installed_package and repo_package_build > inst_package_build: + return True return False