2023-12-24 15:51:44 +08:00
|
|
|
import argparse
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
2023-12-30 22:07:01 +08:00
|
|
|
if __name__ == "__main__":
|
2023-12-24 15:51:44 +08:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
# script -py <py_version> (3.8 ~ 3.12)
|
2023-12-30 22:07:01 +08:00
|
|
|
parser.add_argument("-py", type=str, help="python version")
|
|
|
|
parser.add_argument("-all", help="用所有的python版本编译", action="store_true")
|
2023-12-24 15:51:44 +08:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# 移动到项目根目录
|
2023-12-30 22:07:01 +08:00
|
|
|
os.chdir("./mods/dr_game/Difficult_Rocket_rs/src")
|
2023-12-24 15:51:44 +08:00
|
|
|
|
|
|
|
if not args.py:
|
|
|
|
if args.all:
|
2023-12-30 22:07:01 +08:00
|
|
|
all_version = ("38", "39", "310", "311", "312")
|
2023-12-24 15:51:44 +08:00
|
|
|
for py_version in all_version:
|
|
|
|
try:
|
2023-12-30 22:07:01 +08:00
|
|
|
subprocess.run([f"python{py_version}", "setup.py", "build"])
|
2023-12-24 15:51:44 +08:00
|
|
|
except FileNotFoundError:
|
2023-12-30 22:07:01 +08:00
|
|
|
print(f"python{py_version} not found")
|
2023-12-24 15:51:44 +08:00
|
|
|
else:
|
2023-12-30 22:07:01 +08:00
|
|
|
subprocess.run([sys.executable, "setup.py", "build"])
|
2023-12-24 15:51:44 +08:00
|
|
|
else:
|
2023-12-30 22:07:01 +08:00
|
|
|
subprocess.run([args.py, "setup.py", "build"])
|
|
|
|
|
2023-12-24 15:51:44 +08:00
|
|
|
# post
|
2023-12-30 22:07:01 +08:00
|
|
|
subprocess.run([sys.executable, "post_build.py"])
|