-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_binary.py
More file actions
58 lines (47 loc) · 2.1 KB
/
make_binary.py
File metadata and controls
58 lines (47 loc) · 2.1 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
49
50
51
52
53
54
55
56
57
58
"""Build script for creating binary executables using Nuitka. Uses platform detection to determine whether to output Mac or Windows binary."""
import subprocess
import sys
from pathlib import Path
def platform_helper() -> tuple:
"""Return platform-specific flags for binary builds for macos or windows."""
if sys.platform == "darwin":
return ("--macos-create-app-bundle", "--macos-app-icon=none") # TODO: Remove second flag if/when we add a cross-platform icon for the app.
else:
return ("--windows-console-mode=disable","--output-filename=manuscript2slides")
def build() -> int:
"""Run Nuitka build command."""
print("Building manuscript2slides...")
print("This will take 15-20 minutes on first build.\n")
# Nuitka build command
cmd = [
sys.executable, # Use the current Python interpreter
"-m",
"nuitka",
"--standalone", # Changed from --onefile to reduce antivirus false positives
"--enable-plugin=pyside6",
"--user-package-configuration-file=nuitka-package.config.yaml",
"--include-package-data=pptx",
"--include-package-data=docx",
"--include-package-data=manuscript2slides",
"--noinclude-qt-translations",
"--assume-yes-for-downloads",
*platform_helper(),
"--output-dir=deploy",
str(Path("src") / "manuscript2slides" / "gui.py"),
]
# Run build
result = subprocess.run(cmd, encoding="utf-8", errors="replace")
if result.returncode == 0:
print("\nPASS Build successful!")
if sys.platform == "darwin":
print(f"Output: {Path('deploy') / 'gui.app'}")
print("\nTo distribute: Rename gui.app to manuscript2slides.app, then ZIP it")
else:
print(f"Output: {Path('deploy') / 'gui.dist' / 'manuscript2slides.exe'}")
print("\nTo distribute: Rename gui.dist to manuscript2slides, then ZIP the folder")
else:
print("\nFAIL Build failed!")
print("Check the output above for errors.")
return result.returncode
if __name__ == "__main__":
sys.exit(build())