diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 077cded..2645448 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -32,6 +32,8 @@ jobs: - name: Install dependencies run: | + VERSION=$(dunamai from any --no-metadata --style pep440) + poetry version $VERSION poetry install --with=docs - name: Create docs diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b17a3e6..8ce87b0 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -37,10 +37,6 @@ jobs: run: | VERSION=$(dunamai from any --no-metadata --style pep440) poetry version $VERSION - echo "from __future__ import annotations - - __version__: str = \"$VERSION\"" > \ - src/async_wrapper/_version.py poetry build - name: Release to PyPI diff --git a/src/async_wrapper/__init__.py b/src/async_wrapper/__init__.py index 942c3d0..0c7a145 100644 --- a/src/async_wrapper/__init__.py +++ b/src/async_wrapper/__init__.py @@ -1,6 +1,7 @@ from __future__ import annotations -from ._version import __version__ # noqa: F401 +from typing import Any + from .convert import async_to_sync, sync_to_async, toggle_func from .queue import Queue, create_queue from .task_group import TaskGroupWrapper, create_task_group_wrapper @@ -18,3 +19,15 @@ "create_queue", "wait_for", ] + +__version__: str + + +def __getattr__(name: str) -> Any: # pragma: no cover + from importlib.metadata import version + + if name == "__version__": + return version("async_wrapper") + + error_msg = f"The attribute named {name!r} is undefined." + raise AttributeError(error_msg) diff --git a/src/async_wrapper/_version.py b/src/async_wrapper/_version.py deleted file mode 100644 index bde5688..0000000 --- a/src/async_wrapper/_version.py +++ /dev/null @@ -1,3 +0,0 @@ -from __future__ import annotations - -__version__: str = "0.0.0"