-
Notifications
You must be signed in to change notification settings - Fork 2
/
versioninfo.py
74 lines (58 loc) · 1.83 KB
/
versioninfo.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
73
74
import io
import os
import sys
__LXML_VERSION = None
def version():
global __LXML_VERSION
if __LXML_VERSION is None:
with open(os.path.join(get_base_dir(), 'version.txt')) as f:
__LXML_VERSION = f.read().strip()
return __LXML_VERSION
def branch_version():
return version()[:3]
def is_pre_release():
version_string = version()
return "a" in version_string or "b" in version_string
def dev_status():
_version = version()
if 'a' in _version:
return 'Development Status :: 3 - Alpha'
elif 'b' in _version or 'c' in _version:
return 'Development Status :: 4 - Beta'
else:
return 'Development Status :: 5 - Production/Stable'
def changes():
"""Extract part of changelog pertaining to version.
"""
_version = version()
with io.open(os.path.join(get_base_dir(), "CHANGES.txt"), 'r', encoding='utf8') as f:
lines = []
for line in f:
if line.startswith('====='):
if len(lines) > 1:
break
if lines:
lines.append(line)
elif line.startswith(_version):
lines.append(line)
return ''.join(lines[:-1])
def create_version_h():
"""Create lxml-version.h
"""
lxml_version = version()
# make sure we have a triple part version number
parts = lxml_version.split('-')
while parts[0].count('.') < 2:
parts[0] += '.0'
lxml_version = '-'.join(parts).replace('a', '.alpha').replace('b', '.beta')
version_h = open(
os.path.join(get_base_dir(), 'src', 'lxml', 'includes', 'lxml-version.h'),
'w')
version_h.write('''\
#ifndef LXML_VERSION_STRING
#define LXML_VERSION_STRING "%s"
#endif
''' % lxml_version)
version_h.close()
def get_base_dir():
return os.path.abspath(os.path.dirname(sys.argv[0]))