-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathupdate_version.py
executable file
·32 lines (26 loc) · 1.26 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
#!/usr/bin/python
# This script automatically creates a list of examples by reading the header in all problem.c files.
import glob
import subprocess
ghash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip()
with open("version.txt") as f:
celmechversion = f.readlines()[0].strip()
print("Updating version to "+celmechversion)
with open("src/disturbing_function.c") as f:
celmechlines = f.readlines()
for i,l in enumerate(celmechlines):
if "**VERSIONLINE**" in l:
celmechlines[i] = "const char* celmech_version_str = \""+celmechversion+"\"; // **VERSIONLINE** This line gets updated automatically. Do not edit manually.\n"
with open("src/disturbing_function.c", "w") as f:
f.writelines(celmechlines)
with open("setup.py") as f:
setuplines = f.readlines()
for i,l in enumerate(setuplines):
if "version='" in l:
setuplines[i] = " version='"+celmechversion+"',\n"
if "GITHASHAUTOUPDATE" in l:
setuplines[i] = " ghash_arg = \"-DCELMECHGITHASH="+ghash+"\" #GITHASHAUTOUPDATE\n"
with open("setup.py", "w") as f:
f.writelines(setuplines)
print("To commit, copy and paste:")
print("\ngit commit -a -m \"Updating version to "+celmechversion+"\"")