diff --git a/.github/workflows/setup.sh b/.github/workflows/setup.sh
index 2324c371..27a7f8d4 100755
--- a/.github/workflows/setup.sh
+++ b/.github/workflows/setup.sh
@@ -12,7 +12,7 @@ pacman --noconfirm -Syu
# main dependencies
pacman --noconfirm -Sy base-devel devtools git pyalpm python-cerberus python-inflection python-passlib python-requests python-srcinfo python-systemd sudo
# make dependencies
-pacman --noconfirm -Sy python-build python-installer python-wheel
+pacman --noconfirm -Sy python-build python-flit python-installer python-wheel
# optional dependencies
if [[ -z $MINIMAL_INSTALL ]]; then
# VCS support
diff --git a/Dockerfile b/Dockerfile
index d9964d94..3ea34628 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -29,7 +29,7 @@ COPY "docker/install-aur-package.sh" "/usr/local/bin/install-aur-package"
## install package dependencies
## darcs is not installed by reasons, because it requires a lot haskell packages which dramatically increase image size
RUN pacman -Sy --noconfirm --asdeps devtools git pyalpm python-cerberus python-inflection python-passlib python-requests python-srcinfo && \
- pacman -Sy --noconfirm --asdeps python-build python-installer python-wheel && \
+ pacman -Sy --noconfirm --asdeps python-build python-flit python-installer python-wheel && \
pacman -Sy --noconfirm --asdeps breezy mercurial python-aiohttp python-aiohttp-cors python-boto3 python-cryptography python-jinja python-requests-unixsocket python-systemd rsync subversion && \
runuser -u build -- install-aur-package python-aioauth-client python-aiohttp-apispec-git python-aiohttp-jinja2 \
python-aiohttp-debugtoolbar python-aiohttp-session python-aiohttp-security
@@ -39,7 +39,7 @@ RUN pacman -Sy --noconfirm --asdeps devtools git pyalpm python-cerberus python-i
COPY --chown=build . "/home/build/ahriman"
## create package archive and install it
RUN cd "/home/build/ahriman" && \
- make VERSION=$(python -c "from src.ahriman.version import __version__; print(__version__)") archlinux && \
+ make VERSION=$(python -c "from src.ahriman import __version__; print(__version__)") archlinux && \
cp ./*-src.tar.xz "package/archlinux" && \
cd "package/archlinux" && \
runuser -u build -- makepkg --noconfirm --install --skipchecksums && \
diff --git a/Makefile b/Makefile
index ca03e19e..d263636d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
PROJECT := ahriman
-FILES := AUTHORS CONTRIBUTING.md COPYING Makefile README.md SECURITY.md docs package src setup.py tox.ini web.png
+FILES := AUTHORS CONTRIBUTING.md COPYING Makefile README.md SECURITY.md docs package pyproject.toml src tox.ini web.png
TARGET_FILES := $(addprefix $(PROJECT)/, $(FILES))
IGNORE_FILES := package/archlinux src/.mypy_cache
@@ -38,7 +38,7 @@ html: specification
tox -e docs-html
push: specification archlinux
- git add package/archlinux/PKGBUILD src/ahriman/version.py docs/ahriman-architecture.svg docs/ahriman.1 docs/completions/
+ git add package/archlinux/PKGBUILD src/ahriman/__init__.py docs/ahriman-architecture.svg package/share/man/man1/ahriman.1 package/share/bash-completion/completions/_ahriman package/share/zsh/site-functions/_ahriman
git commit -m "Release $(VERSION)"
git tag "$(VERSION)"
git push
@@ -56,4 +56,4 @@ version:
ifndef VERSION
$(error VERSION is required, but not set)
endif
- sed -i 's/^__version__ = .*/__version__ = "$(VERSION)"/' src/ahriman/version.py
+ sed -i 's/^__version__ = .*/__version__ = "$(VERSION)"/' src/ahriman/__init__.py
diff --git a/docs/ahriman.rst b/docs/ahriman.rst
index dfec08f9..63f24be2 100644
--- a/docs/ahriman.rst
+++ b/docs/ahriman.rst
@@ -12,17 +12,6 @@ Subpackages
ahriman.models
ahriman.web
-Submodules
-----------
-
-ahriman.version module
-----------------------
-
-.. automodule:: ahriman.version
- :members:
- :no-undoc-members:
- :show-inheritance:
-
Module contents
---------------
diff --git a/docs/conf.py b/docs/conf.py
index 45586562..38ed6d92 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -15,7 +15,7 @@ import sys
from pathlib import Path
-from ahriman.version import __version__
+from ahriman import __version__
basedir = Path(__file__).resolve().parent.parent / "src"
diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD
index ece2e6b1..e68dd738 100644
--- a/package/archlinux/PKGBUILD
+++ b/package/archlinux/PKGBUILD
@@ -8,7 +8,7 @@ arch=('any')
url="https://github.com/arcan1s/ahriman"
license=('GPL3')
depends=('devtools>=1:1.0.0' 'git' 'pyalpm' 'python-cerberus' 'python-inflection' 'python-passlib' 'python-requests' 'python-srcinfo')
-makedepends=('python-build' 'python-installer' 'python-wheel')
+makedepends=('python-build' 'python-flit' 'python-installer' 'python-wheel')
optdepends=('breezy: -bzr packages support'
'darcs: -darcs packages support'
'mercurial: -hg packages support'
@@ -45,8 +45,10 @@ package() {
python -m installer --destdir="$pkgdir" "dist/$pkgname-$pkgver-py3-none-any.whl"
- # python-installer actually thinks that you cannot just copy files to root
- # thus we need to copy them manually
+ # thanks too PEP517, which we all wanted, you need to install data files manually nowadays
+ pushd package && find . -type f -exec install -Dm644 "{}" "$pkgdir/usr/{}" \; && popd
+
+ # keep usr/share configs as reference and copy them to /etc
install -Dm644 "$pkgdir/usr/share/$pkgname/settings/ahriman.ini" "$pkgdir/etc/ahriman.ini"
install -Dm644 "$pkgdir/usr/share/$pkgname/settings/ahriman.ini.d/logging.ini" "$pkgdir/etc/ahriman.ini.d/logging.ini"
diff --git a/package/bin/ahriman b/package/bin/ahriman
deleted file mode 100755
index 34fe177f..00000000
--- a/package/bin/ahriman
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exec python -B -m ahriman.application.ahriman "$@"
\ No newline at end of file
diff --git a/docs/completions/bash/_ahriman b/package/share/bash-completion/completions/_ahriman
similarity index 100%
rename from docs/completions/bash/_ahriman
rename to package/share/bash-completion/completions/_ahriman
diff --git a/docs/ahriman.1 b/package/share/man/man1/ahriman.1
similarity index 100%
rename from docs/ahriman.1
rename to package/share/man/man1/ahriman.1
diff --git a/docs/completions/zsh/_ahriman b/package/share/zsh/site-functions/_ahriman
similarity index 100%
rename from docs/completions/zsh/_ahriman
rename to package/share/zsh/site-functions/_ahriman
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..dc786818
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,84 @@
+[build-system]
+requires = ["flit_core"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "ahriman"
+
+description = "ArcH linux ReposItory MANager"
+readme = "README.md"
+
+requires-python = ">=3.11"
+
+license = {file = "COPYING"}
+authors = [
+ {name = "ahriman team"},
+]
+
+dependencies = [
+ "cerberus",
+ "inflection",
+ "passlib",
+ "requests",
+ "srcinfo",
+]
+
+dynamic = ["version"]
+
+[project.urls]
+Documentation = "https://ahriman.readthedocs.io/"
+Repository = "https://github.com/arcan1s/ahriman"
+Changelog = "https://github.com/arcan1s/ahriman/releases"
+
+[project.scripts]
+ahriman = "ahriman.application.ahriman:run"
+
+[project.optional-dependencies]
+check = [
+ "autopep8",
+ "bandit",
+ "mypy",
+ "pylint",
+]
+ docs = [
+ "Sphinx",
+ "argparse-manpage",
+ "pydeps",
+ "shtab",
+ "sphinx-argparse",
+ "sphinx-rtd-theme>=1.1.1", # https://stackoverflow.com/a/74355734
+ ]
+journald = [
+ "systemd-python",
+]
+# FIXME technically this dependency is required, but in some cases we do not have access to
+# the libalpm which is required in order to install the package. Thus in case if we do not
+# really need to run the application we can move it to "optional" dependencies
+pacman = [
+ "pyalpm",
+]
+s3 = [
+ "boto3",
+]
+tests = [
+ "pytest",
+ "pytest-aiohttp",
+ "pytest-cov",
+ "pytest-helpers-namespace",
+ "pytest-mock",
+ "pytest-resource-path",
+ "pytest-spec",
+]
+web = [
+ "Jinja2",
+ "aioauth-client",
+ "aiohttp",
+ "aiohttp-apispec",
+ "aiohttp_cors",
+ "aiohttp_jinja2",
+ "aiohttp_debugtoolbar",
+ "aiohttp_session",
+ "aiohttp_security",
+ "cryptography",
+ "requests-unixsocket", # required by unix socket support
+]
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 9125e058..00000000
--- a/setup.py
+++ /dev/null
@@ -1,158 +0,0 @@
-from pathlib import Path
-from setuptools import find_packages, setup
-from typing import Any
-
-
-metadata_path = Path(__file__).resolve().parent / "src/ahriman/version.py"
-metadata: dict[str, Any] = {}
-with metadata_path.open() as metadata_file:
- exec(metadata_file.read(), metadata) # pylint: disable=exec-used
-
-
-setup(
- name="ahriman",
-
- version=metadata["__version__"],
- zip_safe=False,
-
- description="ArcH linux ReposItory MANager",
-
- author="ahriman team",
- author_email="",
- url="https://github.com/arcan1s/ahriman",
-
- license="GPL3",
-
- packages=find_packages("src"),
- package_dir={"": "src"},
- package_data={"": ["py.typed"]},
-
- dependency_links=[
- ],
- install_requires=[
- "cerberus",
- "inflection",
- "passlib",
- "requests",
- "srcinfo",
- ],
- setup_requires=[
- ],
- tests_require=[
- "pytest",
- "pytest-aiohttp",
- "pytest-cov",
- "pytest-helpers-namespace",
- "pytest-mock",
- "pytest-spec",
- "pytest-resource-path",
- ],
-
- include_package_data=True,
- scripts=[
- "package/bin/ahriman",
- ],
- data_files=[
- # configuration
- ("share/ahriman/settings", [
- "package/share/ahriman/settings/ahriman.ini",
- ]),
- ("share/ahriman/settings/ahriman.ini.d", [
- "package/share/ahriman/settings/ahriman.ini.d/logging.ini",
- ]),
- # systemd files
- ("lib/systemd/system", [
- "package/lib/systemd/system/ahriman@.service",
- "package/lib/systemd/system/ahriman@.timer",
- "package/lib/systemd/system/ahriman-web@.service",
- ]),
- # templates
- ("share/ahriman/templates", [
- "package/share/ahriman/templates/api.jinja2",
- "package/share/ahriman/templates/build-status.jinja2",
- "package/share/ahriman/templates/email-index.jinja2",
- "package/share/ahriman/templates/error.jinja2",
- "package/share/ahriman/templates/repo-index.jinja2",
- "package/share/ahriman/templates/shell",
- "package/share/ahriman/templates/telegram-index.jinja2",
- ]),
- ("share/ahriman/templates/build-status", [
- "package/share/ahriman/templates/build-status/alerts.jinja2",
- "package/share/ahriman/templates/build-status/key-import-modal.jinja2",
- "package/share/ahriman/templates/build-status/login-modal.jinja2",
- "package/share/ahriman/templates/build-status/package-add-modal.jinja2",
- "package/share/ahriman/templates/build-status/package-info-modal.jinja2",
- "package/share/ahriman/templates/build-status/package-rebuild-modal.jinja2",
- "package/share/ahriman/templates/build-status/table.jinja2",
- ]),
- ("share/ahriman/templates/static", [
- "package/share/ahriman/templates/static/favicon.ico",
- ]),
- ("share/ahriman/templates/utils", [
- "package/share/ahriman/templates/utils/bootstrap-scripts.jinja2",
- "package/share/ahriman/templates/utils/style.jinja2",
- ]),
- # man pages
- ("share/man/man1", [
- "docs/ahriman.1",
- ]),
- # shell completions
- ("share/bash-completion/completions", [
- "docs/completions/bash/_ahriman",
- ]),
- ("share/zsh/site-functions", [
- "docs/completions/zsh/_ahriman",
- ]),
- ],
-
- extras_require={
- "check": [
- "autopep8",
- "bandit",
- "mypy",
- "pylint",
- ],
- "docs": [
- "Sphinx",
- "argparse-manpage",
- "pydeps",
- "shtab",
- "sphinx-argparse",
- "sphinx-rtd-theme>=1.1.1", # https://stackoverflow.com/a/74355734
- ],
- "journald": [
- "systemd-python",
- ],
- # FIXME technically this dependency is required, but in some cases we do not have access to
- # the libalpm which is required in order to install the package. Thus in case if we do not
- # really need to run the application we can move it to "optional" dependencies
- "pacman": [
- "pyalpm",
- ],
- "s3": [
- "boto3",
- ],
- "tests": [
- "pytest",
- "pytest-aiohttp",
- "pytest-cov",
- "pytest-helpers-namespace",
- "pytest-mock",
- "pytest-resource-path",
- "pytest-spec",
- ],
- "web": [
- "Jinja2",
- "aioauth-client",
- "aiohttp",
- "aiohttp-apispec",
- "aiohttp_cors",
- "aiohttp_jinja2",
- "aiohttp_debugtoolbar",
- "aiohttp_session",
- "aiohttp_security",
- "cryptography",
- "requests-unixsocket", # required by unix socket support
- ],
- },
-)
diff --git a/src/ahriman/__init__.py b/src/ahriman/__init__.py
index 8fc622e9..6a292068 100644
--- a/src/ahriman/__init__.py
+++ b/src/ahriman/__init__.py
@@ -17,3 +17,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
+__version__ = "2.10.2"
diff --git a/src/ahriman/application/ahriman.py b/src/ahriman/application/ahriman.py
index c5ff1f43..af185e76 100644
--- a/src/ahriman/application/ahriman.py
+++ b/src/ahriman/application/ahriman.py
@@ -19,13 +19,12 @@
#
# pylint: disable=too-many-lines
import argparse
-import sys
import tempfile
from pathlib import Path
from typing import TypeVar
-from ahriman import version
+from ahriman import __version__
from ahriman.application import handlers
from ahriman.core.util import enum_values, extract_user
from ahriman.models.action import Action
@@ -85,7 +84,7 @@ def _parser() -> argparse.ArgumentParser:
parser.add_argument("-q", "--quiet", help="force disable any logging", action="store_true")
parser.add_argument("--unsafe", help="allow to run ahriman as non-ahriman user. Some actions might be unavailable",
action="store_true")
- parser.add_argument("-V", "--version", action="version", version=version.__version__)
+ parser.add_argument("-V", "--version", action="version", version=__version__)
subparsers = parser.add_subparsers(title="command", help="command to run", dest="command", required=True)
@@ -1000,18 +999,15 @@ def _set_web_parser(root: SubParserAction) -> argparse.ArgumentParser:
return parser
-def run() -> None:
+def run() -> int:
"""
run application instance
+
+ Returns:
+ int: application status code
"""
- if __name__ == "__main__":
- args_parser = _parser()
- args = args_parser.parse_args()
+ args_parser = _parser()
+ args = args_parser.parse_args()
- handler: handlers.Handler = args.handler
- status = handler.execute(args)
-
- sys.exit(status)
-
-
-run()
+ handler: handlers.Handler = args.handler
+ return handler.execute(args)
diff --git a/src/ahriman/application/handlers/service_updates.py b/src/ahriman/application/handlers/service_updates.py
index 405e9b28..1a27b3f2 100644
--- a/src/ahriman/application/handlers/service_updates.py
+++ b/src/ahriman/application/handlers/service_updates.py
@@ -19,7 +19,7 @@
#
import argparse
-from ahriman import version
+from ahriman import __version__
from ahriman.application.application import Application
from ahriman.application.handlers import Handler
from ahriman.core.configuration import Configuration
@@ -49,7 +49,7 @@ class ServiceUpdates(Handler):
remote = Package.from_aur("ahriman", application.repository.pacman, None)
release = remote.version.rsplit("-", 1)[-1] # we don't store pkgrel locally, so we just append it
- local_version = f"{version.__version__}-{release}"
+ local_version = f"{__version__}-{release}"
# technically we would like to compare versions, but it is fine to raise an exception in case if locally
# installed package is newer than in AUR
diff --git a/src/ahriman/application/handlers/versions.py b/src/ahriman/application/handlers/versions.py
index af4f59e8..dbde2dbb 100644
--- a/src/ahriman/application/handlers/versions.py
+++ b/src/ahriman/application/handlers/versions.py
@@ -24,7 +24,7 @@ import sys
from collections.abc import Generator
from importlib import metadata
-from ahriman import version
+from ahriman import __version__
from ahriman.application.handlers import Handler
from ahriman.core.configuration import Configuration
from ahriman.core.formatters import VersionPrinter
@@ -52,7 +52,7 @@ class Versions(Handler):
configuration(Configuration): configuration instance
report(bool): force enable or disable reporting
"""
- VersionPrinter(f"Module version {version.__version__}",
+ VersionPrinter(f"Module version {__version__}",
{"Python": sys.version}).print(verbose=False, separator=" ")
packages = Versions.package_dependencies("ahriman")
VersionPrinter("Installed packages", dict(packages)).print(verbose=False, separator=" ")
diff --git a/src/ahriman/application/lock.py b/src/ahriman/application/lock.py
index 88197518..5ec58764 100644
--- a/src/ahriman/application/lock.py
+++ b/src/ahriman/application/lock.py
@@ -22,7 +22,7 @@ import argparse
from types import TracebackType
from typing import Literal, Self
-from ahriman import version
+from ahriman import __version__
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import DuplicateRunError
from ahriman.core.log import LazyLogging
@@ -77,9 +77,9 @@ class Lock(LazyLogging):
check web server version
"""
status = self.reporter.get_internal()
- if status.version is not None and status.version != version.__version__:
+ if status.version is not None and status.version != __version__:
self.logger.warning("status watcher version mismatch, our %s, their %s",
- version.__version__, status.version)
+ __version__, status.version)
def check_user(self) -> None:
"""
diff --git a/src/ahriman/core/alpm/remote/remote.py b/src/ahriman/core/alpm/remote/remote.py
index bbf88e49..bcd150d1 100644
--- a/src/ahriman/core/alpm/remote/remote.py
+++ b/src/ahriman/core/alpm/remote/remote.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-from ahriman import version
+from ahriman import __version__
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.log import LazyLogging
from ahriman.models.aur_package import AURPackage
@@ -43,7 +43,7 @@ class Remote(LazyLogging):
directly, whereas ``multisearch`` splits search one by one and finds intersection between search results.
"""
- DEFAULT_USER_AGENT = f"ahriman/{version.__version__}"
+ DEFAULT_USER_AGENT = f"ahriman/{__version__}"
@classmethod
def info(cls, package_name: str, *, pacman: Pacman) -> AURPackage:
diff --git a/src/ahriman/core/status/web_client.py b/src/ahriman/core/status/web_client.py
index 44a98d07..55e1cdc4 100644
--- a/src/ahriman/core/status/web_client.py
+++ b/src/ahriman/core/status/web_client.py
@@ -24,7 +24,7 @@ import requests
from collections.abc import Generator
from urllib.parse import quote_plus as urlencode
-from ahriman import version
+from ahriman import __version__
from ahriman.core.configuration import Configuration
from ahriman.core.log import LazyLogging
from ahriman.core.status.client import Client
@@ -141,11 +141,11 @@ class WebClient(Client, LazyLogging):
if use_unix_socket:
import requests_unixsocket # type: ignore[import]
session: requests.Session = requests_unixsocket.Session()
- session.headers["User-Agent"] = f"ahriman/{version.__version__}"
+ session.headers["User-Agent"] = f"ahriman/{__version__}"
return session
session = requests.Session()
- session.headers["User-Agent"] = f"ahriman/{version.__version__}"
+ session.headers["User-Agent"] = f"ahriman/{__version__}"
self._login(session)
return session
diff --git a/src/ahriman/models/user.py b/src/ahriman/models/user.py
index 08bc58c9..494a5685 100644
--- a/src/ahriman/models/user.py
+++ b/src/ahriman/models/user.py
@@ -17,9 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
+from secrets import token_urlsafe as generate_password
from dataclasses import dataclass, replace
from passlib.hash import sha512_crypt
-from passlib.pwd import genword as generate_password
from typing import Self
from ahriman.models.user_access import UserAccess
@@ -104,8 +104,7 @@ class User:
Returns:
str: random string which contains letters and numbers
"""
- password: str = generate_password(length=length)
- return password
+ return generate_password(length)[:length]
def check_credentials(self, password: str, salt: str) -> bool:
"""
diff --git a/src/ahriman/version.py b/src/ahriman/version.py
deleted file mode 100644
index 6a292068..00000000
--- a/src/ahriman/version.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Copyright (c) 2021-2023 ahriman team.
-#
-# This file is part of ahriman
-# (see https://github.com/arcan1s/ahriman).
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-__version__ = "2.10.2"
diff --git a/src/ahriman/web/apispec.py b/src/ahriman/web/apispec.py
index 6295c6ac..a7ccc918 100644
--- a/src/ahriman/web/apispec.py
+++ b/src/ahriman/web/apispec.py
@@ -22,7 +22,7 @@ import aiohttp_apispec # type: ignore[import]
from aiohttp.web import Application
from typing import Any
-from ahriman import version
+from ahriman import __version__
from ahriman.core.configuration import Configuration
@@ -59,7 +59,7 @@ def _info() -> dict[str, Any]:
"name": "GPL3",
"url": "https://raw.githubusercontent.com/arcan1s/ahriman/master/COPYING",
},
- "version": version.__version__,
+ "version": __version__,
}
diff --git a/src/ahriman/web/schemas/internal_status_schema.py b/src/ahriman/web/schemas/internal_status_schema.py
index 537db1af..0515a3e5 100644
--- a/src/ahriman/web/schemas/internal_status_schema.py
+++ b/src/ahriman/web/schemas/internal_status_schema.py
@@ -19,7 +19,7 @@
#
from marshmallow import Schema, fields
-from ahriman import version
+from ahriman import __version__
from ahriman.web.schemas.counters_schema import CountersSchema
from ahriman.web.schemas.status_schema import StatusSchema
@@ -45,5 +45,5 @@ class InternalStatusSchema(Schema):
})
version = fields.String(required=True, metadata={
"description": "Repository version",
- "example": version.__version__,
+ "example": __version__,
})
diff --git a/src/ahriman/web/schemas/package_schema.py b/src/ahriman/web/schemas/package_schema.py
index 5747fcb8..69095173 100644
--- a/src/ahriman/web/schemas/package_schema.py
+++ b/src/ahriman/web/schemas/package_schema.py
@@ -19,7 +19,7 @@
#
from marshmallow import Schema, fields
-from ahriman import version
+from ahriman import __version__
from ahriman.web.schemas.package_properties_schema import PackagePropertiesSchema
from ahriman.web.schemas.remote_schema import RemoteSchema
@@ -35,7 +35,7 @@ class PackageSchema(Schema):
})
version = fields.String(required=True, metadata={
"description": "Package version",
- "example": version.__version__,
+ "example": __version__,
})
remote = fields.Nested(RemoteSchema(), required=True, metadata={
"description": "Package remote properties",
diff --git a/src/ahriman/web/views/status/status.py b/src/ahriman/web/views/status/status.py
index fee72c47..c74688f0 100644
--- a/src/ahriman/web/views/status/status.py
+++ b/src/ahriman/web/views/status/status.py
@@ -21,7 +21,7 @@ import aiohttp_apispec # type: ignore[import]
from aiohttp.web import HTTPBadRequest, HTTPNoContent, Response, json_response
-from ahriman import version
+from ahriman import __version__
from ahriman.models.build_status import BuildStatusEnum
from ahriman.models.counters import Counters
from ahriman.models.internal_status import InternalStatus
@@ -68,7 +68,8 @@ class StatusView(BaseView):
architecture=self.service.architecture,
packages=counters,
repository=self.service.repository.name,
- version=version.__version__)
+ version=__version__,
+ )
return json_response(status.view())
diff --git a/tests/ahriman/application/handlers/test_handler_service_updates.py b/tests/ahriman/application/handlers/test_handler_service_updates.py
index 8be2729b..e6be1e33 100644
--- a/tests/ahriman/application/handlers/test_handler_service_updates.py
+++ b/tests/ahriman/application/handlers/test_handler_service_updates.py
@@ -2,7 +2,7 @@ import argparse
from pytest_mock import MockerFixture
-from ahriman import version
+from ahriman import __version__
from ahriman.application.handlers import ServiceUpdates
from ahriman.core.configuration import Configuration
from ahriman.core.repository import Repository
@@ -46,7 +46,7 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, reposi
"""
must do not perform any actions if package is up-to-date
"""
- package_ahriman.version = f"{version.__version__}-1"
+ package_ahriman.version = f"{__version__}-1"
args = _default_args(args)
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
diff --git a/tests/ahriman/application/handlers/test_handler_shell.py b/tests/ahriman/application/handlers/test_handler_shell.py
index f870bc20..5a6e32c6 100644
--- a/tests/ahriman/application/handlers/test_handler_shell.py
+++ b/tests/ahriman/application/handlers/test_handler_shell.py
@@ -58,9 +58,11 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, rep
args = _default_args(args)
args.verbose = True
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
+ read_mock = mocker.patch("pathlib.Path.read_text", return_value="")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application_mock = mocker.patch("code.interact")
Shell.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
+ read_mock.assert_called_once_with(encoding="utf8")
print_mock.assert_called_once_with(verbose=False)
diff --git a/tests/ahriman/application/test_ahriman.py b/tests/ahriman/application/test_ahriman.py
index 171306ac..ee27f543 100644
--- a/tests/ahriman/application/test_ahriman.py
+++ b/tests/ahriman/application/test_ahriman.py
@@ -3,6 +3,7 @@ import argparse
from pathlib import Path
from pytest_mock import MockerFixture
+from ahriman.application import ahriman
from ahriman.application.handlers import Handler
from ahriman.models.action import Action
from ahriman.models.build_status import BuildStatusEnum
@@ -822,10 +823,6 @@ def test_run(args: argparse.Namespace, mocker: MockerFixture) -> None:
args.architecture = "x86_64"
args.handler = Handler
- from ahriman.application import ahriman
- mocker.patch.object(ahriman, "__name__", "__main__")
mocker.patch("argparse.ArgumentParser.parse_args", return_value=args)
- exit_mock = mocker.patch("sys.exit")
- ahriman.run()
- exit_mock.assert_called_once_with(1)
+ assert ahriman.run() == 1
diff --git a/tests/ahriman/application/test_lock.py b/tests/ahriman/application/test_lock.py
index a9d9e2b9..17c5e0a0 100644
--- a/tests/ahriman/application/test_lock.py
+++ b/tests/ahriman/application/test_lock.py
@@ -6,7 +6,7 @@ from pathlib import Path
from pytest_mock import MockerFixture
from unittest.mock import call as MockCall
-from ahriman import version
+from ahriman import __version__
from ahriman.application.lock import Lock
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import DuplicateRunError, UnsafeRunError
@@ -33,7 +33,7 @@ def test_check_version(lock: Lock, mocker: MockerFixture) -> None:
must check version correctly
"""
mocker.patch("ahriman.core.status.client.Client.get_internal",
- return_value=InternalStatus(status=BuildStatus(), version=version.__version__))
+ return_value=InternalStatus(status=BuildStatus(), version=__version__))
logging_mock = mocker.patch("logging.Logger.warning")
lock.check_version()
diff --git a/tests/ahriman/models/conftest.py b/tests/ahriman/models/conftest.py
index 239d1460..0ea86ccf 100644
--- a/tests/ahriman/models/conftest.py
+++ b/tests/ahriman/models/conftest.py
@@ -3,7 +3,7 @@ import pytest
from unittest.mock import MagicMock, PropertyMock
-from ahriman import version
+from ahriman import __version__
from ahriman.models.aur_package import AURPackage
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
from ahriman.models.counters import Counters
@@ -55,7 +55,7 @@ def internal_status(counters: Counters) -> InternalStatus:
return InternalStatus(status=BuildStatus(),
architecture="x86_64",
packages=counters,
- version=version.__version__,
+ version=__version__,
repository="aur-clone")
diff --git a/tests/ahriman/test_version.py b/tests/ahriman/test_version.py
deleted file mode 100644
index db4279da..00000000
--- a/tests/ahriman/test_version.py
+++ /dev/null
@@ -1,8 +0,0 @@
-import ahriman.version as version
-
-
-def test_version() -> None:
- """
- version must not be empty
- """
- assert getattr(version, "__version__")
diff --git a/tests/ahriman/web/test_apispec.py b/tests/ahriman/web/test_apispec.py
index 33b4ceaa..f55ce175 100644
--- a/tests/ahriman/web/test_apispec.py
+++ b/tests/ahriman/web/test_apispec.py
@@ -3,7 +3,7 @@ import pytest
from aiohttp.web import Application
from pytest_mock import MockerFixture
-from ahriman import version
+from ahriman import __version__
from ahriman.web.apispec import _info, _security, _servers, setup_apispec
@@ -13,7 +13,7 @@ def test_info() -> None:
"""
info = _info()
assert info["title"] == "ahriman"
- assert info["version"] == version.__version__
+ assert info["version"] == __version__
def test_security() -> None:
diff --git a/tests/ahriman/web/views/status/test_views_status_status.py b/tests/ahriman/web/views/status/test_views_status_status.py
index 4ee95794..a64e4a0d 100644
--- a/tests/ahriman/web/views/status/test_views_status_status.py
+++ b/tests/ahriman/web/views/status/test_views_status_status.py
@@ -3,8 +3,7 @@ import pytest
from aiohttp.test_utils import TestClient
from pytest_mock import MockerFixture
-import ahriman.version as version
-
+from ahriman import __version__
from ahriman.models.build_status import BuildStatusEnum
from ahriman.models.internal_status import InternalStatus
from ahriman.models.package import Package
@@ -37,7 +36,7 @@ async def test_get(client: TestClient, package_ahriman: Package) -> None:
json = await response.json()
assert not response_schema.validate(json)
- assert json["version"] == version.__version__
+ assert json["version"] == __version__
assert json["packages"]
assert json["packages"]["total"] == 1
diff --git a/tox.ini b/tox.ini
index 695512e0..02901bc6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -40,9 +40,9 @@ allowlist_externals =
setenv =
SPHINX_APIDOC_OPTIONS=members,no-undoc-members,show-inheritance
commands =
- /bin/bash -c 'shtab --shell bash --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../docs/completions/bash/_ahriman'
- /bin/bash -c 'shtab --shell zsh --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../docs/completions/zsh/_ahriman'
- argparse-manpage --module ahriman.application.ahriman --function _parser --author "ahriman team" --project-name ahriman --author-email "" --url https://github.com/arcan1s/ahriman --output ../docs/ahriman.1
+ /bin/bash -c 'shtab --shell bash --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/bash-completion/completions/_ahriman'
+ /bin/bash -c 'shtab --shell zsh --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/zsh/site-functions/_ahriman'
+ argparse-manpage --module ahriman.application.ahriman --function _parser --author "ahriman team" --project-name ahriman --author-email "" --url https://github.com/arcan1s/ahriman --output ../package/share/man/man1/ahriman.1
pydeps ahriman -o ../docs/ahriman-architecture.svg --no-config --no-show --cluster
sphinx-apidoc -o ../docs .