diff --git a/pyilcd/__init__.py b/pyilcd/__init__.py index c382c37..4bea6f5 100644 --- a/pyilcd/__init__.py +++ b/pyilcd/__init__.py @@ -45,7 +45,7 @@ from .process_dataset import ProcessDataSet from .source_dataset import SourceDataSet from .unit_group_dataset import UnitGroupDataSet -from .utils import get_version_tuple +from .version import __version__ __all__ = ( "__version__", @@ -94,6 +94,3 @@ "validate_zip_file_unit_group_dataset", "UnitGroupDataSet", ) - - -__version__ = get_version_tuple() diff --git a/pyilcd/utils.py b/pyilcd/utils.py deleted file mode 100644 index f4afc5f..0000000 --- a/pyilcd/utils.py +++ /dev/null @@ -1,18 +0,0 @@ -"""Utilities module for pyilcd.""" - -import importlib.metadata -from typing import Union - - -def get_version_tuple() -> tuple: - """Returns version as (major, minor, micro).""" - - def as_integer(version_str: str) -> Union[int, str]: - try: - return int(version_str) - except ValueError: # pragma: no cover - return version_str # pragma: no cover - - return tuple( - as_integer(v) for v in importlib.metadata.version("pyilcd").strip().split(".") - ) diff --git a/pyilcd/version.py b/pyilcd/version.py new file mode 100644 index 0000000..57dfe74 --- /dev/null +++ b/pyilcd/version.py @@ -0,0 +1,15 @@ +"""Version information for lxmlh package.""" +import pathlib + + +def _get_version(): + """Return the version number.""" + versionFile = pathlib.Path(__file__).parent / "VERSION" + # Read the version number from VERSION file + with open(versionFile, "r", encoding="UTF-8") as vf: + # The full version, including alpha/beta/rc tags + versionList = vf.read().strip().split(".") + return ".".join(versionList) + + +__version__ = _get_version()