-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
67 lines (58 loc) · 1.39 KB
/
build.py
File metadata and controls
67 lines (58 loc) · 1.39 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
import sys
import subprocess
from pathlib import Path
# -------------------------
# Project settings
# -------------------------
PROJECT_NAME = "3D_Project_Manager"
MAIN_SCRIPT = "main.py"
# Files/folders to include
DATA_DIRS = ["data", "icons"]
# Icons by plateform
ICONS = {
"win": "icons/nm.ico",
"darwin": "icons/nm.icns",
"linux": "icons/nm.png"
}
# PyInstaller options
COMMON_OPTIONS = [
"--onefile",
"--noconsole",
]
# -------------------------
# Platform detection
# -------------------------
platform = sys.platform
if platform.startswith("win"):
icon = ICONS["win"]
sep = ";" # separator for --add-data on Windows
elif platform.startswith("darwin"):
icon = ICONS["darwin"]
sep = ":" # separator for macOS/Linux
elif platform.startswith("linux"):
icon = ICONS["linux"]
sep = ":"
else:
raise RuntimeError(f"Non supported platform : {platform}")
# -------------------------
# Build --add-data
# -------------------------
add_data = []
for d in DATA_DIRS:
add_data.append(f"{d}{sep}{d}")
# -------------------------
# Build PyInstaller command
# -------------------------
cmd = [
"pyinstaller",
*COMMON_OPTIONS,
f"--icon={icon}",
*(f"--add-data={ad}" for ad in add_data),
MAIN_SCRIPT
]
print("PyInstaller command:")
print(" ".join(cmd))
# -------------------------
# Execution
# -------------------------
subprocess.run(cmd, check=True)