From 20c8a1708e803eec6cf8aae2ad39d606057d1e30 Mon Sep 17 00:00:00 2001 From: Sylvain Hellegouarch Date: Thu, 18 Apr 2024 15:47:28 +0200 Subject: [PATCH] read version from metadata Signed-off-by: Sylvain Hellegouarch --- CHANGELOG.md | 10 +++++++++- chaosk8s/__init__.py | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 198eb5e..5866dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ## [Unreleased][] -[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-kubernetes/compare/0.38.1...HEAD +[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-kubernetes/compare/0.38.2...HEAD + +## [0.38.2][] - 2024-04-18 + +[0.38.2]: https://github.com/chaostoolkit/chaostoolkit-kubernetes/compare/0.38.1...0.38.2 + +### Fixed + +* Read version from package metadata ## [0.38.1][] - 2024-04-18 diff --git a/chaosk8s/__init__.py b/chaosk8s/__init__.py index bc7982f..8f8051a 100644 --- a/chaosk8s/__init__.py +++ b/chaosk8s/__init__.py @@ -1,6 +1,7 @@ import logging import os import os.path +from importlib.metadata import version, PackageNotFoundError from typing import List from chaoslib.discovery.discover import ( @@ -12,7 +13,11 @@ from kubernetes import client, config __all__ = ["create_k8s_api_client", "discover", "__version__"] -__version__ = "0.35.0" +try: + __version__ = version("chaostoolkit-kubernetes") +except PackageNotFoundError: + __version__ = "unknown" + logger = logging.getLogger("chaostoolkit")