-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_version.py
30 lines (26 loc) · 918 Bytes
/
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
import os
def read_version():
"""Reads the version number from a VERSION file."""
with open("VERSION") as version_file:
version = version_file.read().strip()
print(f"Read version: {version}")
return version
def update_setuppy_version(version):
"""Updates the version number in setup.py."""
updated = False
with open("setup.py", "r") as file:
lines = file.readlines()
with open("setup.py", "w") as file:
for line in lines:
if "version=" in line:
file.write(f" version='{version}',\n")
updated = True
else:
file.write(line)
return updated
if __name__ == "__main__":
version = read_version()
if update_setuppy_version(version):
print(f"setup.py has been successfully updated to version {version}.")
else:
print("No version update required in setup.py.")