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:
2023-08-11 03:01:18 +03:00
parent 3b3ef43863
commit 480c3a54b8
34 changed files with 147 additions and 266 deletions

View File

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

View File

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

View File

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

View File

@ -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=" ")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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__,
}

View File

@ -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__,
})

View File

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

View File

@ -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())