-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
65 lines (57 loc) · 1.59 KB
/
build.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
63
64
65
import os
from shutil import copytree
from shutil import copyfile
from shutil import rmtree
from pathlib import Path
retained_files = [
"assets",
"pygame",
"main.exe",
"_socket.pyd",
"base_library.zip",
"pyexpat.pyd",
"select.pyd"
]
retained_keywords = [
"python",
"SDL",
"lib"
]
if __name__ == "__main__":
root_path = Path(r"./").absolute()
path = Path(r"./dist/main/").absolute()
print("Cleaning files...")
if os.path.exists("./build"):
rmtree("./build")
if os.path.exists("./dist"):
try:
rmtree("./dist")
except OSError:
pass
print("DONE")
print("Building...")
os.system("pyinstaller --icon=logo.ico -w main.py --upx-dir=" + str(root_path))
print("DONE")
print("Removing files...")
for file_name in os.listdir(path):
if file_name not in retained_files:
flag = False
for keyword in retained_keywords:
if keyword in str(file_name):
flag = True
if not flag:
try:
os.remove(str(path) + "\\" + str(file_name))
except FileNotFoundError:
pass
except PermissionError:
pass
print("DONE")
print("Copying files...")
copytree(r"./assets", str(path) + "\\" + "assets")
copyfile(r"./logo.ico", "./dist/main/logo.ico")
print("DONE")
print("Renaming files...")
os.rename("./dist/main/main.exe", "./dist/main/Arena.exe")
os.rename("./dist/main", "./dist/Arena")
print("DONE")