-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathbuild.py
More file actions
27 lines (23 loc) · 805 Bytes
/
build.py
File metadata and controls
27 lines (23 loc) · 805 Bytes
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
import shutil
import sys
from pathlib import Path
from platform import system
from subprocess import CalledProcessError, run
project_dir = Path(".")
assets_dir = project_dir / "assets"
main_py = project_dir / "main.py"
icon_file = assets_dir / ("duck.ico" if system() == "Windows" else "duck.png")
for dir_to_remove in ["dist", "build"]:
dir_path = project_dir / dir_to_remove
if dir_path.exists():
shutil.rmtree(dir_path)
pyinstaller_cmd = [
"pyinstaller", "--onefile", "--windowed",
f"--add-data={assets_dir}{';' if system() == 'Windows' else ':'}{assets_dir}",
f"--name=DuckTrack", f"--icon={icon_file}", str(main_py)
]
try:
run(pyinstaller_cmd, check=True)
except CalledProcessError as e:
print("An error occurred while running PyInstaller:", e)
sys.exit(1)