-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtestversion.py
72 lines (57 loc) · 1.83 KB
/
testversion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
import os
import re
ROOT = os.path.dirname(__file__)
def main():
version_versionpy = get_version_versionpy()
version_metayaml = get_version_metayaml()
print('Version strings found:')
print(version_versionpy)
print(version_metayaml)
try:
for i in range(0,3):
assert version_versionpy[i] == version_metayaml[i]
except Exception as e:
print(e)
raise Exception('Invalid version strings encountered')
def get_version_projecttoml():
"""
Extract the version string from the pyproject.toml file
"""
pattern = re.compile(r'^version\s*=\s*"(\d+\.\d+.\d+)"\s*$')
f = open(os.path.join(ROOT, 'pyproject.toml'))
lines = f.readlines()
for line in lines:
match = re.match(pattern, line)
if match:
version = match.groups(1)[0]
return [int(i) for i in version.split('.')]
return None
def get_version_versionpy():
"""
Extract the version string from the _version.py file
"""
pattern = re.compile(r'^__version__\s*=\s*[\'"](\d+\.\d+.\d+)[\'"]\s*$')
f = open(os.path.join(ROOT, 'pyqint', '_version.py'))
lines = f.readlines()
for line in lines:
match = re.match(pattern, line)
if match:
version = match.groups(1)[0]
return [int(i) for i in version.split('.')]
return None
def get_version_metayaml():
"""
Extract the version string from the meta.yaml file
"""
pattern = re.compile(r'^\s*version\s*:\s*"(\d+\.\d+.\d+)"\s*$')
f = open(os.path.join(ROOT, 'meta.yaml'))
lines = f.readlines()
for line in lines:
match = re.match(pattern, line)
if match:
version = match.groups(1)[0]
return [int(i) for i in version.split('.')]
return None
if __name__ == '__main__':
main()