-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathladder_zip.py
More file actions
84 lines (62 loc) · 2.3 KB
/
ladder_zip.py
File metadata and controls
84 lines (62 loc) · 2.3 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Script for creating Ladder Manager compatible Zip archives.
import os
import argparse
import sub_module # Important, do not remove!
from version import update_version_txt
from bot_loader import LadderZip
root_dir = os.path.dirname(os.path.abspath(__file__))
# Files or folders common to all bots.
common = [
(os.path.join("sharpy-sc2", "jsonpickle"), "jsonpickle"),
(os.path.join("sharpy-sc2", "sharpy"), "sharpy"),
(os.path.join("sharpy-sc2", "python-sc2", "sc2"), "sc2"),
(os.path.join("sharpy-sc2", "sc2pathlibp"), "sc2pathlibp"),
("requirements.txt", None),
("version.txt", None),
(os.path.join("sharpy-sc2", "config.py"), "config.py"),
("config.ini", None),
(os.path.join("sharpy-sc2", "ladder.py"), "ladder.py"),
("ladderbots.json", None),
]
# Files or folders to be ignored from the archive.
ignored = [
"__pycache__",
]
protoss_zip = LadderZip(
"ProtossSharpyExample", "Protoss", [("protossbot", None), (os.path.join("protossbot", "run.py"), "run.py")], common
)
terran_zip = LadderZip(
"TerranSharpyExample", "Terran", [("terranbot", None), (os.path.join("terranbot", "run.py"), "run.py")], common
)
zerg_zip = LadderZip(
"ZergSharpyExample", "Zerg", [("zergbot", None), (os.path.join("zergbot", "run.py"), "run.py")], common
)
zip_types = {
"protoss": protoss_zip,
"terran": terran_zip,
"zerg": zerg_zip,
# All
"all": None,
}
def main():
zip_keys = list(zip_types.keys())
parser = argparse.ArgumentParser(
description="Create a Ladder Manager ready zip archive for SC2 AI, AI Arena, Probots, ..."
)
parser.add_argument("-n", "--name", help=f"Bot name: {zip_keys}.")
parser.add_argument("-e", "--exe", help="Also make executable (Requires pyinstaller)", action="store_true")
args = parser.parse_args()
bot_name = args.name
if not os.path.exists("dummy"):
os.mkdir("dummy")
update_version_txt()
if bot_name == "all" or not bot_name:
zip_keys.remove("all")
for key in zip_keys:
zip_types.get(key).create_ladder_zip(args.exe)
else:
if bot_name not in zip_keys:
raise ValueError(f"Unknown bot: {bot_name}, allowed values are: {zip_keys}")
zip_types.get(bot_name).create_ladder_zip(args.exe)
if __name__ == "__main__":
main()