diff --git a/pyproject.toml b/pyproject.toml index 19fcae5..6ce3344 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,6 +84,7 @@ where=["src"] write_to = "src/snkf/_version.py" version_scheme = "python-simplified-semver" local_scheme="no-local-version" +fallback_version="v99-dev" [tool.coverage.report] precision = 2 diff --git a/src/snkf/__init__.py b/src/snkf/__init__.py index 59fe7a8..7dfa9c1 100644 --- a/src/snkf/__init__.py +++ b/src/snkf/__init__.py @@ -25,15 +25,10 @@ "load_from_yaml", ] -try: - # -- Distribution mode -- - # import from _version.py generated by setuptools_scm during release - from ._version import version as __version__ -except ImportError: # pragma: no cover - # -- Source mode -- - # use setuptools_scm to get the current version from src using git - from os import path as _path - - from setuptools_scm import get_version as _gv +from importlib.metadata import version, PackageNotFoundError - __version__ = _gv(_path.join(_path.dirname(__file__), _path.pardir)) +try: + __version__ = version(__name__) +except PackageNotFoundError: + # package is not installed + pass