Merge pull request #9 from yingziwu/vercmp

fix bug on pkgver compare
This commit is contained in:
依云 2023-08-23 13:15:19 +08:00 committed by GitHub
commit fa4f743045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 12 deletions

View file

@ -15,6 +15,7 @@ DEPENDENCIES
- setuptools
- tornado, > 3.1
- pyinotify, tested with 0.9.4
- pyalpm, tested with 0.10.6
NOTE
====

View file

@ -2,24 +2,16 @@ 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)
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:
return parse_arch_version(self.version) < parse_arch_version(other.version)
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'],
entry_points = {
'console_scripts': [
'archreposrv = archrepo2.archreposrv:main',