-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_executables.py
executable file
·63 lines (50 loc) · 1.52 KB
/
build_executables.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
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
58
59
60
61
62
import sys
import subprocess
RETRIES = 3
def get_ostag() -> str:
"""Determine operating system tag from sys.platform."""
if sys.platform.startswith("linux"):
return "linux"
elif sys.platform.startswith("win"):
return "win64"
elif sys.platform.startswith("darwin"):
return "mac"
raise ValueError(f"platform {sys.platform!r} not supported")
def get_cctag() -> str:
"""Determine operating system tag from sys.platform."""
if sys.platform.startswith("linux"):
return "icc"
elif sys.platform.startswith("win"):
return "icl"
elif sys.platform.startswith("darwin"):
return "icc"
raise ValueError(f"platform {sys.platform!r} not supported")
def mfpymake_run_command(args) -> bool:
success = False
for idx in range(RETRIES):
p = subprocess.run(args)
if p.returncode == 0:
success = True
break
print(f"{args[0]} run {idx + 1}/{RETRIES} failed...rerunning")
return success
if __name__ == "__main__":
cmd = [
"make-code-json",
"-f",
f"{get_ostag()}/code.json",
"--verbose",
]
if not mfpymake_run_command(cmd):
raise RuntimeError(f"could not run {cmd[0]}")
cmd = [
"make-program",
":",
f"--appdir={get_ostag()}",
"-fc=ifort",
f"-cc={get_cctag()}",
f"--zip={get_ostag()}.zip",
"--keep",
]
if not mfpymake_run_command(cmd):
raise RuntimeError("could not build the executables")