-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.py
57 lines (46 loc) · 1.64 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
53
54
55
56
57
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
site_packages = Path(Path.cwd() / ".venv" / "Lib" / "site-packages")
icon_path = Path(Path.cwd() / "Runtime" / "Images" / "icon.ico")
ffmpeg_encoder_script = Path(Path.cwd() / "FFMPEGAudioEncoder.py")
additional_hooks = Path(Path.cwd() / "Packages")
# 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",
"-F",
"--paths",
str(site_packages),
"-n",
"FFMPEGAudioEncoder",
"-w",
"--onefile",
f"--icon={str(icon_path)}",
str(ffmpeg_encoder_script),
f"--additional-hooks-dir={additional_hooks}",
]
)
# get exe string based on os
exe_str = ".exe"
# ensure output of exe
success = "Did not complete successfully"
if (
Path(Path("dist") / f"FFMPEGAudioEncoder{exe_str}").is_file()
and str(build_job.returncode) == "0"
):
success = f'\nSuccess!\nPath to exe: {str(Path.cwd() / (Path(Path("dist") / f"FFMPEGAudioEncoder{exe_str}")))}'
# change directory back to original directory
os.chdir(ffmpeg_encoder_script.parent)
# return success message
return success
if __name__ == "__main__":
build = build_app()
print(build)