diff --git a/niftypet/nipet/__init__.py b/niftypet/nipet/__init__.py index 135e302e..61bf7043 100644 --- a/niftypet/nipet/__init__.py +++ b/niftypet/nipet/__init__.py @@ -2,6 +2,16 @@ """initialise the NiftyPET NIPET package""" __author__ = ("Pawel J. Markiewicz", "Casper O. da Costa-Luis") __copyright__ = "Copyright 2020" +# version detector. Precedence: installed dist, git, 'UNKNOWN' +try: + from ._dist_ver import __version__ +except ImportError: + try: + from setuptools_scm import get_version + + __version__ = get_version(root="../..", relative_to=__file__) + except (ImportError, LookupError): + __version__ = "UNKNOWN" import logging import os diff --git a/pyproject.toml b/pyproject.toml index c1d8738a..2e4331aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,7 @@ requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "ninst>=0.8.0", "numpy>=1.14", "miutil[cuda]>=0.4.0", "scikit-build>=0.11.0", "cmake>=3.18", "ninja"] + +[tool.setuptools_scm] +write_to = "niftypet/nipet/_dist_ver.py" +write_to_template = "__version__ = '{version}'\n"