replace subprocess with pyalpm

This commit is contained in:
bgme 2023-08-15 14:11:29 +08:00
parent 9187984b6b
commit 668140131b
2 changed files with 3 additions and 5 deletions

View file

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

View file

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