-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_executable.py
51 lines (42 loc) · 1.44 KB
/
generate_executable.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
import os
import shutil
import sys
import platform
import distro
import argparse
def main(zip):
try:
shutil.rmtree("iq_sim_client")
except:
print("no directory iq_sim_client")
try:
os.remove("iq_sim_client.zip")
except:
print("no file iq_sim_client.zip")
if sys.platform == "linux" or sys.platform == "linux2":
shutil.copytree("mavp2p/mavp2p_linux",
"iq_sim_client/mavp2p/mavp2p_linux")
output_filename = "iq_sim_client_linux"
distro_name = distro.name(pretty=True).replace(" ", "_").replace(".", "_")
print(distro_name)
output_filename = output_filename + "_" + distro_name
elif sys.platform == "darwin":
print("todo")
return
elif sys.platform == "win32":
shutil.copytree("mavp2p/mavp2p_windows",
"iq_sim_client/mavp2p/mavp2p_windows")
output_filename = "iq_sim_client_windows"
os.system("pyinstaller -F app.py --distpath iq_sim_client")
shutil.copytree("imgs", "iq_sim_client/imgs")
if zip:
print("zipping application")
shutil.make_archive(output_filename, 'zip', "iq_sim_client")
else:
print("not zipping application")
if __name__ == "__main__":
# parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("--zip", help="zip the executable", action="store_true")
args = parser.parse_args()
main(args.zip)