Updated for pkg_resources

This commit is contained in:
Dimitris Zlatanidis 2024-03-13 12:14:03 +02:00
parent 291fc92aba
commit 107bfe25eb

View file

@ -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