-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
48 lines (40 loc) · 1.72 KB
/
build.py
File metadata and controls
48 lines (40 loc) · 1.72 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
import os
import shutil
import subprocess
import sys
def build_exe():
"""
Сборка проекта в исполняемый файл с помощью PyInstaller
"""
print("Начинаю сборку проекта в EXE-файл...")
# Создаем директорию для сборки, если она не существует
if not os.path.exists("build"):
os.makedirs("build")
# Параметры для PyInstaller
pyinstaller_args = [
"pyinstaller",
"--name=NovelEngine",
"--onefile", # Создаем один EXE-файл
"--windowed", # Без консольного окна
"--icon=Assets/icon.ico" if os.path.exists("Assets/icon.ico") else "",
"--add-data=Assets;Assets", # Добавляем ресурсы
"--add-data=story;story",
"--add-data=engine;engine",
"main.py"
]
# Удаляем пустые аргументы
pyinstaller_args = [arg for arg in pyinstaller_args if arg]
# Запускаем PyInstaller
try:
subprocess.run(pyinstaller_args, check=True)
print("Сборка успешно завершена!")
# Копируем EXE-файл в корневую директорию
if os.path.exists("dist/NovelEngine.exe"):
shutil.copy("dist/NovelEngine.exe", "NovelEngine.exe")
print("Исполняемый файл скопирован в корневую директорию: NovelEngine.exe")
return True
except subprocess.CalledProcessError as e:
print(f"Ошибка при сборке: {e}")
return False
if __name__ == "__main__":
build_exe()