-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcompile.py
More file actions
76 lines (59 loc) · 1.95 KB
/
compile.py
File metadata and controls
76 lines (59 loc) · 1.95 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
import os
import platform
import subprocess
import plistlib
from utils.config import VERSION
def patch_macos_plist(app_name):
plist_path = os.path.join("dist", f"{app_name}.app", "Contents", "Info.plist")
if not os.path.exists(plist_path):
print("Info.plist not found, skipping version patch")
return
with open(plist_path, "rb") as f:
plist = plistlib.load(f)
plist["CFBundleShortVersionString"] = VERSION # About menu
plist["CFBundleVersion"] = VERSION # build number
with open(plist_path, "wb") as f:
plistlib.dump(plist, f)
print(f"Patched Info.plist with version {VERSION}")
def build():
system = platform.system()
name = "Ghost"
entry_script = "ghost.py"
icon = "data/icon-win.png" if system == "Windows" else "data/icon.png"
args = [
"pyinstaller",
f"--name={name}",
"--onefile",
"--clean",
"--noconfirm",
"--windowed",
"--noconsole",
f"--icon={icon}",
"--hidden-import=discord",
"--hidden-import=discord.ext.commands",
"--hidden-import=PIL.ImageTk",
"--hidden-import=PIL._tkinter_finder",
"--collect-submodules=discord",
entry_script
]
if system == "Windows":
args += [
"--paths=.venv\\Lib\\site-packages",
"--add-data=data\\*;data",
"--add-data=data\\fonts\\*;data/fonts",
"--add-data=data\\icons\\*;data/icons"
]
else:
args += [
"--paths=.venv/lib/python3.10/site-packages",
"--add-data=data/*:data",
"--add-data=data/fonts/*:data/fonts",
"--add-data=data/icons/*:data/icons",
"--osx-bundle-identifier=fun.benny.ghost"
]
print(f"🔨 Building Ghost {VERSION} for {system}...")
subprocess.run(args, check=True)
if system == "Darwin":
patch_macos_plist(name)
if __name__ == "__main__":
build()