From 2a1dd91b3a1369193e8e6e55412d55042129746a Mon Sep 17 00:00:00 2001 From: phi Date: Sat, 24 Feb 2024 00:20:01 +0900 Subject: [PATCH] fix: remove _version.py --- .github/workflows/docs.yaml | 2 ++ .github/workflows/publish.yaml | 4 ---- src/async_wrapper/__init__.py | 15 ++++++++++++++- src/async_wrapper/_version.py | 3 --- 4 files changed, 16 insertions(+), 8 deletions(-) delete mode 100644 src/async_wrapper/_version.py 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"