comparison sat/tools/utils.py @ 2576:cb7bf936d8e8

setup, tools(utils): fixed versioning in setup and getRepositoryData
author Goffi <goffi@goffi.org>
date Fri, 06 Apr 2018 16:47:40 +0200
parents 18e2ca5f798e
children 3e4e78de9cca
comparison
equal deleted inserted replaced
2575:824ef7f64286 2576:cb7bf936d8e8
202 if not hg_data: 202 if not hg_data:
203 log.debug(u"Mercurial not available or working, trying package version") 203 log.debug(u"Mercurial not available or working, trying package version")
204 try: 204 try:
205 import pkg_resources 205 import pkg_resources
206 pkg_version = pkg_resources.get_distribution(C.APP_NAME_FILE).version 206 pkg_version = pkg_resources.get_distribution(C.APP_NAME_FILE).version
207 version, hg_node, hg_distance = pkg_version.split('-') 207 version, local_id = pkg_version.split('+', 1)
208 except ImportError: 208 except ImportError:
209 log.warning("pkg_resources not available, can't get package data") 209 log.warning("pkg_resources not available, can't get package data")
210 except pkg_resources.DistributionNotFound: 210 except pkg_resources.DistributionNotFound:
211 log.warning("can't retrieve package data") 211 log.warning("can't retrieve package data")
212 except ValueError: 212 except ValueError:
213 log.warning(u"package version doesn't fit: {pkg_version}".format(pkg_version=pkg_version)) 213 log.info(u"no local version id in package: {pkg_version}".format(pkg_version=pkg_version))
214 else: 214 else:
215 version = version.replace('.dev0', 'D')
215 if version != C.APP_VERSION: 216 if version != C.APP_VERSION:
216 log.error("Incompatible version ({version}) and pkg_version ({pkg_version})".format( 217 log.warning("Incompatible version ({version}) and pkg_version ({pkg_version})".format(
217 version=C.APP_VERSION, pkg_version=pkg_version)) 218 version=C.APP_VERSION, pkg_version=pkg_version))
218 else: 219 else:
220 try:
221 hg_node, hg_distance = local_id.split('.')
222 except ValueError:
223 log.warning("Version doesn't specify repository data")
219 hg_data = {'node_short': hg_node, 'distance': hg_distance} 224 hg_data = {'node_short': hg_node, 'distance': hg_distance}
220 225
221 repos_cache_dict = hg_data 226 repos_cache_dict = hg_data
222 227
223 if as_string: 228 if as_string: