diff --git a/src/msspec/version.py b/src/msspec/version.py index 38f29be..9eb35c6 100644 --- a/src/msspec/version.py +++ b/src/msspec/version.py @@ -1,28 +1,31 @@ # coding: utf-8 # vim: set et sw=4 ts=4 sts=4 nu ai cc=+0 fdm=indent mouse=a: +from setuptools_scm import get_version from pkg_resources import parse_version, DistributionNotFound, get_distribution from msspec.misc import LOGGER import os +# find the version number +# 1- Try to read it from the git info +# 2- If it fails, try to read it from the VERSION file +# 3- If it fails, try to read it from the distribution file + try: - # try to find the version from egg info file - __version__ = get_distribution(__name__.strip('.version')).version -except DistributionNotFound: - # otherwise try to get it from the SCM + v = get_version(root='../../', relative_to=__file__, version_scheme="post-release") + v = parse_version(v) + if v._version.post[-1] == 0: + __version__ = v.base_version + else: + __version__ = v.public +except (LookupError, ImportError): try: - from setuptools_scm import get_version - v = get_version(root='../../', relative_to=__file__, version_scheme="post-release") - v = parse_version(v) - if v._version.post[-1] == 0: - __version__ = v.base_version - else: - __version__ = v.public - except (LookupError, ModuleNotFoundError): - # Ok, so there may be a VERSION file to look for it + f = os.path.join(os.path.dirname(__file__), "../VERSION") + with open(f, "r") as fd: + __version__ = fd.read().strip('\n ') + except: try: - f = os.path.join(os.path.dirname(__file__), "../VERSION") - with open(f, "r") as fd: - __version__ = fd.read().strip('\n ') - except: + __version__ = get_distribution(__name__.strip('.version')).version + except DistributionNotFound: LOGGER.error("Unable to get the version number!") +