-
Notifications
You must be signed in to change notification settings - Fork 19
/
update_version.py
42 lines (36 loc) · 1.24 KB
/
update_version.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
import argparse
Parser = argparse.ArgumentParser(description="update_version", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
Parser.add_argument('version', help='version')
args = Parser.parse_args()
with open("documentation_source/source/conf.py", "r") as f:
lines = f.readlines()
with open("documentation_source/source/conf.py", "w") as f:
for line in lines:
if "version =" in line:
f.write('version = "{}"\n'.format(args.version))
elif "release =" in line:
f.write('release = "{}"\n'.format(args.version))
else:
f.write(line)
try:
with open("setup.py", "r") as f:
lines = f.readlines()
with open("setup.py", "w") as f:
for line in lines:
if "__version__ =" in line:
f.write('__version__ = "{}"\n'.format(args.version))
else:
f.write(line)
except:
pass
try:
with open("pyproject.toml", "r") as f:
lines = f.readlines()
with open("pyproject.toml", "w") as f:
for line in lines:
if "version =" in line:
f.write('version = "{}"\n'.format(args.version))
else:
f.write(line)
except:
pass