-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdate_version.py
More file actions
58 lines (35 loc) · 1.15 KB
/
update_version.py
File metadata and controls
58 lines (35 loc) · 1.15 KB
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
import os
import datetime
version_str = '0.2.5'
dir0 = os.path.dirname( __file__ )
date_str = str( datetime.date.today() )
# update __init__.py
fpath = os.path.join(dir0, 'src', 'rft1d', '__init__.py')
with open(fpath, 'r') as f:
lines = f.readlines()
for i,line in enumerate(lines):
if line.startswith('__version__'):
break
lines[i] = f"__version__ = '{version_str}' # {date_str}\n"
with open(fpath, 'w') as f:
f.writelines( lines )
# update pyproject.toml
fpath = os.path.join(dir0, 'pyproject.toml')
with open(fpath, 'r') as f:
lines = f.readlines()
for i,line in enumerate(lines):
if line.startswith('version'):
break
lines[i] = f'version = "{version_str}"\n'
with open(fpath, 'w') as f:
f.writelines( lines )
# update README.md
fpath = os.path.join(dir0, 'README.md')
with open(fpath, 'r') as f:
lines = f.readlines()
for i,line in enumerate(lines):
if line.startswith('![version]'):
break
lines[i] = f"\n"
with open(fpath, 'w') as f:
f.writelines( lines )