forked from geo-yuheng/Yuheng
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre_build_process.py
More file actions
33 lines (29 loc) · 931 Bytes
/
pre_build_process.py
File metadata and controls
33 lines (29 loc) · 931 Bytes
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
import os
def main() -> None:
global_const_data = [
{x.split("=")[0]: x.split("=")[1]}
for x in open("src/yuheng/basic/const.py", "r")
.read()
.replace(" ", "")
.replace('"', "")
.split("\n")
if x != ""
]
global_const = {}
for tag in global_const_data:
global_const = {**global_const, **tag}
print(global_const)
# run
build_file_read = open("pyproject.toml", "r", encoding="utf-8")
build_file_content = (
build_file_read.read()
.replace("__YUHENG_CORE_NAME__", global_const["YUHENG_CORE_NAME"])
.replace("__YUHENG_VERSION__", global_const["YUHENG_VERSION"])
)
build_file_read.close()
os.remove("pyproject.toml")
build_file_write = open("pyproject.toml", "w", encoding="utf-8")
build_file_write.write(build_file_content)
build_file_write.close()
if __name__ == "__main__":
main()