mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-10-31 05:43:41 +00:00 
			
		
		
		
	full support of pep517
Since llast upgrade build is broken. Lets fully migrate to pyproject.toml. Note for maintaners: because data_files option is deprectated (see https://github.com/pypa/setuptools/discussions/2648) you will have to install files manually inside your packaging process
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/workflows/setup.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/setup.sh
									
									
									
									
										vendored
									
									
								
							| @ -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 | ||||
|  | ||||
| @ -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 && \ | ||||
|  | ||||
							
								
								
									
										6
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								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 | ||||
|  | ||||
| @ -12,17 +12,6 @@ Subpackages | ||||
|    ahriman.models | ||||
|    ahriman.web | ||||
|  | ||||
| Submodules | ||||
| ---------- | ||||
|  | ||||
| ahriman.version module | ||||
| ---------------------- | ||||
|  | ||||
| .. automodule:: ahriman.version | ||||
|    :members: | ||||
|    :no-undoc-members: | ||||
|    :show-inheritance: | ||||
|  | ||||
| Module contents | ||||
| --------------- | ||||
|  | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
|  | ||||
| @ -1,3 +0,0 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| exec python -B -m ahriman.application.ahriman "$@" | ||||
							
								
								
									
										84
									
								
								pyproject.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								pyproject.toml
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||
| ] | ||||
							
								
								
									
										158
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										158
									
								
								setup.py
									
									
									
									
									
								
							| @ -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 | ||||
|         ], | ||||
|     }, | ||||
| ) | ||||
| @ -17,3 +17,4 @@ | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| __version__ = "2.10.2" | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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=" ") | ||||
|  | ||||
| @ -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: | ||||
|         """ | ||||
|  | ||||
| @ -17,7 +17,7 @@ | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| 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: | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -17,9 +17,9 @@ | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| 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: | ||||
|         """ | ||||
|  | ||||
| @ -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 <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| __version__ = "2.10.2" | ||||
| @ -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__, | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -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__, | ||||
|     }) | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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()) | ||||
|  | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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() | ||||
|  | ||||
| @ -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") | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,8 +0,0 @@ | ||||
| import ahriman.version as version | ||||
|  | ||||
|  | ||||
| def test_version() -> None: | ||||
|     """ | ||||
|     version must not be empty | ||||
|     """ | ||||
|     assert getattr(version, "__version__") | ||||
| @ -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: | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
|  | ||||
							
								
								
									
										6
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								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 . | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user