diff --git a/royalnet/__init__.py b/royalnet/__init__.py new file mode 100644 index 00000000..5b3ac131 --- /dev/null +++ b/royalnet/__init__.py @@ -0,0 +1,3 @@ +import pkg_resources + +__version__ = pkg_resources.get_distribution(__name__).version diff --git a/royalnet/backpack/commands/royalnetversion.py b/royalnet/backpack/commands/royalnetversion.py index c4583194..ceb7d6e2 100644 --- a/royalnet/backpack/commands/royalnetversion.py +++ b/royalnet/backpack/commands/royalnetversion.py @@ -1,4 +1,4 @@ -import royalnet.version +import royalnet from royalnet.commands import * @@ -12,7 +12,7 @@ class RoyalnetversionCommand(Command): if __debug__: message = f"ℹ️ Royalnet [url=https://github.com/Steffo99/royalnet/]Unreleased[/url]\n" else: - message = f"ℹ️ Royalnet [url=https://github.com/Steffo99/royalnet/releases/tag/{royalnet.version.semantic}]{royalnet.version.semantic}[/url]\n" - if "69" in royalnet.version.semantic: + message = f"ℹ️ Royalnet [url=https://github.com/Steffo99/royalnet/releases/tag/{royalnet.__version__}]{royalnet.__version__}[/url]\n" + if "69" in royalnet.__version__: message += "(Nice.)" await data.reply(message) diff --git a/royalnet/backpack/stars/api_royalnet_version.py b/royalnet/backpack/stars/api_royalnet_version.py index 3e04b114..c9a4612f 100644 --- a/royalnet/backpack/stars/api_royalnet_version.py +++ b/royalnet/backpack/stars/api_royalnet_version.py @@ -1,4 +1,4 @@ -import royalnet.version as rv +import royalnet import royalnet.constellation.api as rca import royalnet.utils as ru @@ -12,5 +12,5 @@ class ApiRoyalnetVersionStar(rca.ApiStar): async def get(self, data: rca.ApiData) -> ru.JSON: """Get the current Royalnet version.""" return { - "semantic": rv.semantic + "semantic": royalnet.__version__ } diff --git a/royalnet/backpack/stars/docs.py b/royalnet/backpack/stars/docs.py index a955326e..365d3830 100644 --- a/royalnet/backpack/stars/docs.py +++ b/royalnet/backpack/stars/docs.py @@ -4,7 +4,7 @@ from royalnet.constellation import PageStar from royalnet.constellation.api import ApiStar from starlette.requests import Request from starlette.responses import Response, HTMLResponse -from royalnet.version import semantic +import royalnet backtick = "\u0060" @@ -26,7 +26,7 @@ class DocsStar(PageStar): "info": { "description": "Autogenerated Royalnet API documentation", "title": "Royalnet", - "version": f"{semantic}", + "version": f"{royalnet.__version__}", }, "paths": paths, "components": { diff --git a/royalnet/generate.py b/royalnet/generate.py index c0366bf8..80e18944 100644 --- a/royalnet/generate.py +++ b/royalnet/generate.py @@ -1,7 +1,6 @@ import toml import importlib import click -from .version import semantic p = click.echo diff --git a/royalnet/utils/sentry.py b/royalnet/utils/sentry.py index 1d9b9b02..41f33941 100644 --- a/royalnet/utils/sentry.py +++ b/royalnet/utils/sentry.py @@ -2,7 +2,7 @@ import logging import sys import traceback from typing import * -from royalnet.version import semantic +import royalnet import functools try: @@ -24,7 +24,7 @@ def init_sentry(sentry_cfg: Dict[str, Any]): if sentry_sdk is None: raise ImportError("`sentry` extra is not installed") log.debug("Initializing Sentry...") - release = f"royalnet@{semantic}" + release = f"royalnet@{royalnet.__version__}" sentry_sdk.init(sentry_cfg["dsn"], integrations=[AioHttpIntegration(), SqlalchemyIntegration(), diff --git a/royalnet/version.py b/royalnet/version.py deleted file mode 100644 index 667c3b11..00000000 --- a/royalnet/version.py +++ /dev/null @@ -1 +0,0 @@ -semantic = "5.10.4"