apache-ignite
118 строк · 3.3 Кб
1# Licensed to the Apache Software Foundation (ASF) under one or more
2# contributor license agreements. See the NOTICE file distributed with
3# this work for additional information regarding copyright ownership.
4# The ASF licenses this file to You under the Apache License, Version 2.0
5# (the "License"); you may not use this file except in compliance with
6# the License. You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""
17Module contains ignite version utility class.
18"""
19import re20from distutils.version import LooseVersion21
22from ignitetest import __version__23
24
25class IgniteVersion(LooseVersion):26"""27Container for Ignite versions which makes versions simple to compare.
28
29distutils.version.LooseVersion (and StrictVersion) has robust comparison and ordering logic.
30
31Example:
32
33v27 = IgniteVersion("2.7.0")
34v28 = IgniteVersion("2.8.1")
35assert v28 > v27 # assertion passes!
36"""
37
38DEV_VERSION = "dev"39DEFAULT_PROJECT = "ignite"40
41def __init__(self, vstring=None):42if vstring == self.DEV_VERSION:43self.project = self.DEFAULT_PROJECT44version = vstring45else:46match = re.match(r'([a-zA-Z]*)-*([\d(dev)]+.*)', vstring)47self.project = self.DEFAULT_PROJECT if not match.group(1) else match.group(1)48version = match.group(2)49
50self.is_dev = version == self.DEV_VERSION51
52if self.is_dev:53version = __version__ # we may also parse pom file to gain correct version (in future)54
55super().__init__(version)56
57def __str__(self):58return "%s-%s" % (self.project, "dev" if self.is_dev else super().__str__())59
60def _cmp(self, other):61if isinstance(other, str):62other = IgniteVersion(other)63
64# todo solve comparability issues and uncomment the following65# if self.project != other.project:66# raise Exception("Incomperable versons v1=%s, v2=%s because of different projects" % (self, other))67
68return super()._cmp(other)69
70def __repr__(self):71return "IgniteVersion ('%s')" % str(self)72
73
74DEV_BRANCH = IgniteVersion("dev")75
76# 2.7.x versions
77V_2_7_6 = IgniteVersion("2.7.6")78LATEST_2_7 = V_2_7_679
80# 2.8.x versions
81V_2_8_0 = IgniteVersion("2.8.0")82V_2_8_1 = IgniteVersion("2.8.1")83LATEST_2_8 = V_2_8_184
85# 2.9.x versions
86V_2_9_0 = IgniteVersion("2.9.0")87V_2_9_1 = IgniteVersion("2.9.1")88LATEST_2_9 = V_2_9_189
90# 2.10.x versions
91V_2_10_0 = IgniteVersion("2.10.0")92LATEST_2_10 = V_2_10_093
94# 2.11.x versions
95V_2_11_0 = IgniteVersion("2.11.0")96V_2_11_1 = IgniteVersion("2.11.1")97LATEST_2_11 = V_2_11_198
99# 2.12.x versions
100V_2_12_0 = IgniteVersion("2.12.0")101LATEST_2_12 = V_2_12_0102
103# 2.13.x versions
104V_2_13_0 = IgniteVersion("2.13.0")105LATEST_2_13 = V_2_13_0106
107# 2.14.x versions
108V_2_14_0 = IgniteVersion("2.14.0")109LATEST_2_14 = V_2_14_0110
111# 2.15.x versions
112V_2_15_0 = IgniteVersion("2.15.0")113LATEST_2_15 = V_2_15_0114
115# if you updated the LATEST version
116# please check DEV version in 'tests/ignitetest/__init__.py'
117LATEST = LATEST_2_15118OLDEST = V_2_7_6119