From 9187984b6b94cb7996e566445e1a2c6ea2e4c2a4 Mon Sep 17 00:00:00 2001 From: bgme Date: Tue, 15 Aug 2023 01:30:42 +0800 Subject: [PATCH 1/3] fix bug on pkgver compare --- archrepo2/lib/archpkg.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/archrepo2/lib/archpkg.py b/archrepo2/lib/archpkg.py index f2f9aee..74fd65b 100644 --- a/archrepo2/lib/archpkg.py +++ b/archrepo2/lib/archpkg.py @@ -2,24 +2,18 @@ import os from collections import namedtuple import subprocess import re -from typing import Tuple, List, Dict +from typing import List, Dict -from pkg_resources import parse_version as _parse_version from packaging.version import Version # type: ignore -def parse_arch_version(v: str) -> Tuple[int, Version]: - if ':' in v: - epoch = int(v.split(':', 1)[0]) - else: - epoch = 0 - return epoch, _parse_version(v) - class PkgNameInfo(namedtuple('PkgNameInfo', 'name, version, release, arch')): def __lt__(self, other) -> bool: if self.name != other.name or self.arch != other.arch: return NotImplemented if self.version != other.version: - return parse_arch_version(self.version) < parse_arch_version(other.version) + p = subprocess.Popen(["vercmp", self.version, other.version], stdout=subprocess.PIPE) + output = p.stdout.read() + return int(output) < 0 return float(self.release) < float(other.release) def __gt__(self, other) -> bool: From 668140131b0db2b386c2ed297acfcc9f4b8998e4 Mon Sep 17 00:00:00 2001 From: bgme Date: Tue, 15 Aug 2023 14:11:29 +0800 Subject: [PATCH 2/3] replace subprocess with pyalpm --- archrepo2/lib/archpkg.py | 6 ++---- setup.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/archrepo2/lib/archpkg.py b/archrepo2/lib/archpkg.py index 74fd65b..b0bdaf9 100644 --- a/archrepo2/lib/archpkg.py +++ b/archrepo2/lib/archpkg.py @@ -4,16 +4,14 @@ import subprocess import re from typing import List, Dict -from packaging.version import Version # type: ignore +from pyalpm import vercmp class PkgNameInfo(namedtuple('PkgNameInfo', 'name, version, release, arch')): def __lt__(self, other) -> bool: if self.name != other.name or self.arch != other.arch: return NotImplemented if self.version != other.version: - p = subprocess.Popen(["vercmp", self.version, other.version], stdout=subprocess.PIPE) - output = p.stdout.read() - return int(output) < 0 + return vercmp(self.version, other.version) < 0 return float(self.release) < float(other.release) def __gt__(self, other) -> bool: diff --git a/setup.py b/setup.py index eb6fdb4..2b5a9bd 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name = 'archrepo2', version = archrepo2.__version__, packages = find_packages(), - install_requires = ['tornado>2.4.1', 'pyinotify', 'setuptools'], + install_requires = ['tornado>2.4.1', 'pyinotify', 'pyalpm', 'setuptools'], entry_points = { 'console_scripts': [ 'archreposrv = archrepo2.archreposrv:main', From 5bc16468cbd82a9d89534834807c0e6883afddfb Mon Sep 17 00:00:00 2001 From: bgme Date: Wed, 23 Aug 2023 01:24:18 +0800 Subject: [PATCH 3/3] remove setuptools from setup.py install_requires --- README.rst | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index be0040b..f63edf8 100644 --- a/README.rst +++ b/README.rst @@ -15,6 +15,7 @@ DEPENDENCIES - setuptools - tornado, > 3.1 - pyinotify, tested with 0.9.4 +- pyalpm, tested with 0.10.6 NOTE ==== diff --git a/setup.py b/setup.py index 2b5a9bd..9860ded 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name = 'archrepo2', version = archrepo2.__version__, packages = find_packages(), - install_requires = ['tornado>2.4.1', 'pyinotify', 'pyalpm', 'setuptools'], + install_requires = ['tornado>2.4.1', 'pyinotify', 'pyalpm'], entry_points = { 'console_scripts': [ 'archreposrv = archrepo2.archreposrv:main',