-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
47 lines (37 loc) · 1.22 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
from pathlib import Path
from subprocess import run
import 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
script = Path(Path.cwd() / "autoqpf-cli.py")
icon_path = Path(Path.cwd() / "autoqpf.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.exe",
"-n",
"autoqpf-cli",
"--onefile",
f"--icon={str(icon_path)}",
str(script),
]
)
# ensure output of exe
success = "Did not complete successfully"
if (
Path(Path("dist") / "autoqpf-cli.exe").is_file()
and str(build_job.returncode) == "0"
):
success = f'\nSuccess!\nPath to exe: {str(Path.cwd() / (Path(Path("dist") / "autoqpf-cli.exe")))}'
# change directory back to original directory
os.chdir(script.parent)
# return success message
return success
if __name__ == "__main__":
build = build_app()
print(build)