mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
fix includes glob and trim version from dependencies
This commit is contained in:
parent
bf8a93d080
commit
f3acc01906
3
setup.py
3
setup.py
@ -36,6 +36,7 @@ setup(
|
|||||||
],
|
],
|
||||||
tests_require=[
|
tests_require=[
|
||||||
"pytest",
|
"pytest",
|
||||||
|
"pytest-helpers-namespace",
|
||||||
"pytest-mock",
|
"pytest-mock",
|
||||||
"pytest-pspec",
|
"pytest-pspec",
|
||||||
"pytest-resource-path",
|
"pytest-resource-path",
|
||||||
@ -69,7 +70,7 @@ setup(
|
|||||||
|
|
||||||
extras_require={
|
extras_require={
|
||||||
"html-templates": ["Jinja2"],
|
"html-templates": ["Jinja2"],
|
||||||
"test": ["coverage", "pytest", "pytest-mock", "pytest-pspec", "pytest-resource-path"],
|
"test": ["coverage", "pytest", "pytest-helpers-namespace", "pytest-mock", "pytest-pspec", "pytest-resource-path"],
|
||||||
"web": ["Jinja2", "aiohttp", "aiohttp_jinja2", "requests"],
|
"web": ["Jinja2", "aiohttp", "aiohttp_jinja2", "requests"],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -125,7 +125,7 @@ class Configuration(configparser.RawConfigParser):
|
|||||||
load configuration includes
|
load configuration includes
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
for path in sorted(self.include.glob(".ini")):
|
for path in sorted(self.include.glob("*.ini")):
|
||||||
self.read(path)
|
self.read(path)
|
||||||
except (FileNotFoundError, configparser.NoOptionError):
|
except (FileNotFoundError, configparser.NoOptionError):
|
||||||
pass
|
pass
|
||||||
|
@ -149,6 +149,12 @@ class Package:
|
|||||||
:param path: path to package sources directory
|
:param path: path to package sources directory
|
||||||
:return: list of package dependencies including makedepends array, but excluding packages from this base
|
:return: list of package dependencies including makedepends array, but excluding packages from this base
|
||||||
"""
|
"""
|
||||||
|
# additional function to remove versions from dependencies
|
||||||
|
def trim_version(name: str) -> str:
|
||||||
|
for symbol in ('<', '=', '>'):
|
||||||
|
name = name.split(symbol)[0]
|
||||||
|
return name
|
||||||
|
|
||||||
srcinfo, errors = parse_srcinfo((path / ".SRCINFO").read_text())
|
srcinfo, errors = parse_srcinfo((path / ".SRCINFO").read_text())
|
||||||
if errors:
|
if errors:
|
||||||
raise InvalidPackageInfo(errors)
|
raise InvalidPackageInfo(errors)
|
||||||
@ -159,7 +165,8 @@ class Package:
|
|||||||
depends.extend(package.get("depends", []))
|
depends.extend(package.get("depends", []))
|
||||||
# we are not interested in dependencies inside pkgbase
|
# we are not interested in dependencies inside pkgbase
|
||||||
packages = set(srcinfo["packages"].keys())
|
packages = set(srcinfo["packages"].keys())
|
||||||
return set(depends + makedepends) - packages
|
full_list = set(depends + makedepends) - packages
|
||||||
|
return {trim_version(package_name) for package_name in full_list}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def full_version(epoch: Optional[str], pkgver: str, pkgrel: str) -> str:
|
def full_version(epoch: Optional[str], pkgver: str, pkgrel: str) -> str:
|
||||||
|
14
tests/ahriman/conftest.py
Normal file
14
tests/ahriman/conftest.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from typing import Any, Type, TypeVar
|
||||||
|
|
||||||
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/21611963
|
||||||
|
@pytest.helpers.register
|
||||||
|
def anyvar(cls: Type[T], strict: bool = False) -> T:
|
||||||
|
class AnyVar(cls):
|
||||||
|
def __eq__(self, other: Any) -> bool:
|
||||||
|
return not strict or isinstance(other, cls)
|
||||||
|
return AnyVar()
|
@ -71,6 +71,17 @@ def test_from_json_view_3(package_tpacpi_bat_git: Package) -> None:
|
|||||||
assert Package.from_json(package_tpacpi_bat_git.view()) == package_tpacpi_bat_git
|
assert Package.from_json(package_tpacpi_bat_git.view()) == package_tpacpi_bat_git
|
||||||
|
|
||||||
|
|
||||||
|
def test_dependencies_with_version(mocker: MockerFixture, resource_path_root: Path) -> None:
|
||||||
|
"""
|
||||||
|
must load correct list of dependencies with version
|
||||||
|
"""
|
||||||
|
srcinfo = (resource_path_root / "models" / "package_yay_srcinfo").read_text()
|
||||||
|
|
||||||
|
mocker.patch("pathlib.Path.read_text", return_value=srcinfo)
|
||||||
|
|
||||||
|
assert Package.dependencies(Path("path")) == {"git", "go", "pacman"}
|
||||||
|
|
||||||
|
|
||||||
def test_actual_version(package_ahriman: Package, repository_paths: RepositoryPaths) -> None:
|
def test_actual_version(package_ahriman: Package, repository_paths: RepositoryPaths) -> None:
|
||||||
"""
|
"""
|
||||||
must return same actual_version as version is
|
must return same actual_version as version is
|
||||||
|
@ -14,4 +14,4 @@ pkgbase = tpacpi-bat-git
|
|||||||
source = git+https://github.com/teleshoes/tpacpi-bat.git
|
source = git+https://github.com/teleshoes/tpacpi-bat.git
|
||||||
b2sums = SKIP
|
b2sums = SKIP
|
||||||
|
|
||||||
pkgname = tpacpi-bat-git
|
pkgname = tpacpi-bat-git
|
||||||
|
21
tests/testresources/models/package_yay_srcinfo
Normal file
21
tests/testresources/models/package_yay_srcinfo
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
pkgbase = yay
|
||||||
|
pkgdesc = Yet another yogurt. Pacman wrapper and AUR helper written in go.
|
||||||
|
pkgver = 10.2.0
|
||||||
|
pkgrel = 1
|
||||||
|
url = https://github.com/Jguer/yay
|
||||||
|
arch = i686
|
||||||
|
arch = pentium4
|
||||||
|
arch = x86_64
|
||||||
|
arch = arm
|
||||||
|
arch = armv7h
|
||||||
|
arch = armv6h
|
||||||
|
arch = aarch64
|
||||||
|
license = GPL3
|
||||||
|
makedepends = go
|
||||||
|
depends = pacman>5
|
||||||
|
depends = git
|
||||||
|
optdepends = sudo
|
||||||
|
source = yay-10.2.0.tar.gz::https://github.com/Jguer/yay/archive/v10.2.0.tar.gz
|
||||||
|
sha256sums = 755d049ec09cc20bdcbb004b12ab4e35ba3bb94a7dce9dfa544d24f87deda8aa
|
||||||
|
|
||||||
|
pkgname = yay
|
Loading…
Reference in New Issue
Block a user