-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.py
More file actions
71 lines (61 loc) · 2.34 KB
/
build.py
File metadata and controls
71 lines (61 loc) · 2.34 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
import argparse
import os
import shutil
import sys
APP_NAME = "VolatileSpace"
def build(nonumba, noupx):
"""Build"""
if os.path.exists("dist/VolatileSpace/"):
shutil.rmtree("dist/VolatileSpace/")
hidden_imports = ""
if nonumba:
numba = "--exclude-module numba "
else:
numba = ""
if noupx:
upx = ""
else:
upx = "--upx-dir=upx "
if sys.platform == "linux":
command = f'uv run python -m PyInstaller {hidden_imports}--noconfirm {numba}--windowed --clean --contents-directory "libraries" --name {APP_NAME} "main.py"'
os.system(command)
elif sys.platform == "win32":
command = f'uv run python -m PyInstaller {hidden_imports}--noconfirm {upx}{numba}--windowed --clean --contents-directory "libraries" --icon "images/icon.ico" --name {APP_NAME} "main.py"'
os.system(command)
elif sys.platform == "darwin":
command = f'uv run python -m PyInstaller {hidden_imports}--noconfirm {numba}--windowed --clean --contents-directory "libraries" --icon "images/icon.ico" --name {APP_NAME} "main.py"'
os.system(command)
else:
sys.exit(f"This platform is not supported: {sys.platform}")
shutil.copytree("images/", "dist/VolatileSpace/images/", dirs_exist_ok=True)
shutil.copytree("fonts/", "dist/VolatileSpace/fonts/", dirs_exist_ok=True)
shutil.copytree("parts/", "dist/VolatileSpace/parts/", dirs_exist_ok=True)
shutil.copytree("documentation/", "dist/VolatileSpace/documentation/", dirs_exist_ok=True)
shutil.copytree("Resources/", "dist/VolatileSpace/Resources/", dirs_exist_ok=True)
# cleanup
try:
os.remove(f"{APP_NAME}.spec")
shutil.rmtree("build")
except FileNotFoundError:
pass
def parser():
"""Setup argument parser for CLI"""
parser = argparse.ArgumentParser(
prog="build.py",
description="Setup and build script for endcord",
)
parser._positionals.title = "arguments"
parser.add_argument(
"--nonumba",
action="store_true",
help="Change environment to build or run without numba support",
)
parser.add_argument(
"--noupx",
action="store_true",
help="Build without UPX, useful only on windows",
)
return parser.parse_args()
if __name__ == "__main__":
args = parser()
build(args.nonumba, args.noupx)