diff --git a/src/mpflash/mpflash/config.py b/src/mpflash/mpflash/config.py index f36b81fe..29629c5a 100644 --- a/src/mpflash/mpflash/config.py +++ b/src/mpflash/mpflash/config.py @@ -4,18 +4,15 @@ from pathlib import Path from typing import List -import pkg_resources import platformdirs +from importlib.metadata import version from mpflash.logger import log def get_version(): name = __package__ or "mpflash" - try: - return pkg_resources.get_distribution(name).version - except pkg_resources.DistributionNotFound: - return "Package not found" + return version(name) class MPtoolConfig: @@ -32,16 +29,15 @@ class MPtoolConfig: @property def interactive(self): # No interactions in CI - if os.getenv('GITHUB_ACTIONS') == 'true': + if os.getenv("GITHUB_ACTIONS") == "true": log.warning("Disabling interactive mode in CI") return False return self._interactive - + @interactive.setter - def interactive(self, value:bool): + def interactive(self, value: bool): self._interactive = value - config = MPtoolConfig() __version__ = get_version()