From 3187a4cb32585fbd46d22e9541c62a194a8cb9db Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Thu, 12 Mar 2020 17:55:40 +0100 Subject: [PATCH] Change in version.py To deal with the case of previously installed version of msspec, the order in which the version is checked has changed. 1- test if we can infer the version from the SCM 2- check if a VERSION file exists 3- take the version from the distribution --- src/msspec/version.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) 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!") +