From 668140131b0db2b386c2ed297acfcc9f4b8998e4 Mon Sep 17 00:00:00 2001 From: bgme Date: Tue, 15 Aug 2023 14:11:29 +0800 Subject: [PATCH] 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',