-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
52 lines (40 loc) · 1.37 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
from pathlib import Path
from subprocess import run
import os
from deezy.utils.dependencies import get_executable_string_by_os
def build_app():
# define and create pyinstaller output path
pyinstaller_folder = Path(Path(__file__).parent / "pyinstaller_build")
pyinstaller_folder.mkdir(exist_ok=True)
# define paths before changing directory
deezy_script = Path(Path.cwd() / "deezy.py")
icon_path = Path(Path.cwd() / "icon" / "icon.ico")
# change directory so we output all of pyinstallers files in it's own folder
os.chdir(pyinstaller_folder)
# run pyinstaller command
build_job = run(
[
"pyinstaller",
"-n",
"deezy",
"--onefile",
f"--icon={str(icon_path)}",
str(deezy_script),
]
)
# get exe string based on os
exe_str = get_executable_string_by_os()
# ensure output of exe
success = "Did not complete successfully"
if (
Path(Path("dist") / f"deezy{exe_str}").is_file()
and str(build_job.returncode) == "0"
):
success = f'\nSuccess!\nPath to exe: {str(Path.cwd() / (Path(Path("dist") / f"deezy{exe_str}")))}'
# change directory back to original directory
os.chdir(deezy_script.parent)
# return success message
return success
if __name__ == "__main__":
build = build_app()
print(build)