-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_app.py
More file actions
87 lines (77 loc) · 3.11 KB
/
Copy pathbuild_app.py
File metadata and controls
87 lines (77 loc) · 3.11 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
"""
Build script to create standalone executable
"""
import subprocess
import sys
import os
def build_standalone():
"""Build standalone executable using PyInstaller"""
# Clean previous builds
import shutil
for dir_name in ['build', 'dist', '__pycache__']:
if os.path.exists(dir_name):
print(f"Cleaning {dir_name}...")
shutil.rmtree(dir_name)
# Install PyInstaller if not available
try:
import PyInstaller
except ImportError:
print("Installing PyInstaller...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "pyinstaller"])
# PyInstaller command
cmd = [
"pyinstaller",
"--onedir",
"--windowed",
"--name=GermanLearningTools",
"--icon=docs/images/app_icon.png",
"--hidden-import=customtkinter",
"--hidden-import=learning_german.gui.app",
"--hidden-import=learning_german.markdown_note_generator",
"--hidden-import=learning_german.anki_deck_generator",
"--hidden-import=learning_german.config.settings",
"--hidden-import=learning_german.utils.de_pronunciation_retriever",
"--hidden-import=learning_german.utils.fa_definition_retriever",
"--hidden-import=learning_german.utils.text_processing",
"--hidden-import=learning_german.templates.anki_card_styles",
"--hidden-import=deep_translator",
"--hidden-import=genanki",
"--hidden-import=aiohttp",
"--hidden-import=aiofiles",
"--hidden-import=beautifulsoup4",
"--collect-all=customtkinter",
"--collect-all=learning_german",
"launch_gui.py"
]
# Remove empty icon parameter if no icon exists
cmd = [arg for arg in cmd if arg]
print("Building standalone app...")
print(f"Command: {' '.join(cmd)}")
try:
subprocess.run(cmd, check=True)
print("\n✅ Build successful!")
if sys.platform == "darwin":
app_path = "dist/GermanLearningTools.app"
if os.path.exists(app_path):
print(f"📱 macOS App: {app_path}")
print("\n🔐 To fix permissions, run:")
print(f"xattr -rd com.apple.quarantine '{app_path}'")
else:
print("📱 On macOS: ./dist/GermanLearningTools/GermanLearningTools")
elif sys.platform == "win32":
print("📱 On Windows: dist/GermanLearningTools.exe")
except subprocess.CalledProcessError as e:
print(f"❌ Build failed: {e}")
if __name__ == "__main__":
build_standalone()
# Auto-fix macOS permissions if on macOS
if sys.platform == "darwin":
app_path = "dist/GermanLearningTools.app"
if os.path.exists(app_path):
try:
subprocess.run(["xattr", "-rd", "com.apple.quarantine", app_path], check=True)
print(f"\n✅ macOS permissions fixed - double-click {app_path} to run")
except Exception as e:
print(f"\n⚠️ Manual fix needed: {e}")
print(f"xattr -rd com.apple.quarantine '{app_path}'")