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
This commit is contained in:
parent
162ffa87bd
commit
3187a4cb32
|
@ -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
|
||||
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
|
||||
except (LookupError, ImportError):
|
||||
try:
|
||||
f = os.path.join(os.path.dirname(__file__), "../VERSION")
|
||||
with open(f, "r") as fd:
|
||||
__version__ = fd.read().strip('\n ')
|
||||
except:
|
||||
try:
|
||||
__version__ = get_distribution(__name__.strip('.version')).version
|
||||
except DistributionNotFound:
|
||||
LOGGER.error("Unable to get the version number!")
|
||||
|
||||
|
|
Loading…
Reference in New Issue