diff --git a/poetry.lock b/poetry.lock index 50ec571..150dc02 100644 --- a/poetry.lock +++ b/poetry.lock @@ -260,7 +260,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.9" [[package]] -category = "dev" +category = "main" description = "Read metadata from Python packages" marker = "python_version < \"3.8\"" name = "importlib-metadata" @@ -608,7 +608,7 @@ python-versions = "*" version = "0.1.9" [[package]] -category = "dev" +category = "main" description = "Backport of pathlib-compatible object wrapper for zip files" marker = "python_version < \"3.8\"" name = "zipp" @@ -621,7 +621,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "b53e73cac913a33d502986160a9ed24dd8d9c1ed63218db43e7446fe2f446120" +content-hash = "2810dc20ff30f0e91c106d28e28c377a9516c3a50b6917e848a70510294a2129" python-versions = "^3.7" [metadata.files] diff --git a/pyproject.toml b/pyproject.toml index bd27e8a..3696d7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ homepage = "https://github.com/staticdev/toml-validator" python = "^3.7" tomlkit = "^0.5.9" click = "^7.0" +importlib_metadata = {version = "^1.6.0", python = "<3.8"} [tool.poetry.dev-dependencies] pytest = "^5.3.5" diff --git a/src/toml_validator/__init__.py b/src/toml_validator/__init__.py index 3dc1f76..1db6e80 100644 --- a/src/toml_validator/__init__.py +++ b/src/toml_validator/__init__.py @@ -1 +1,11 @@ -__version__ = "0.1.0" +"""The TOML validator.""" +try: + from importlib.metadata import version, PackageNotFoundError # type: ignore +except ImportError: # pragma: no cover + from importlib_metadata import version, PackageNotFoundError # type: ignore + + +try: + __version__ = version(__name__) +except PackageNotFoundError: # pragma: no cover + __version__ = "unknown"