Skip to content

Commit dbd8456

Browse files
Berik AshimovBerik Ashimov
authored andcommitted
Use importlib.metadata for __version__ to avoid drift
1 parent bc6bc33 commit dbd8456

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/hawkapi_cache/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66

77
from __future__ import annotations
88

9-
__version__ = "0.2.0"
9+
from importlib.metadata import PackageNotFoundError, version
1010

1111
from hawkapi_cache._backends import CacheBackend, MemoryCacheBackend
1212
from hawkapi_cache._decorator import cache
1313
from hawkapi_cache._plugin import CachePlugin, init_cache
1414
from hawkapi_cache._redis import RedisCacheBackend
1515

16+
try:
17+
__version__ = version("hawkapi-cache")
18+
except PackageNotFoundError: # pragma: no cover - running from a source tree without install
19+
__version__ = "0.0.0"
20+
1621
__all__ = [
1722
"CacheBackend",
1823
"CachePlugin",

0 commit comments

Comments
 (0)