Skip to content

Commit 319d634

Browse files
add custom py2app recipe
1 parent fbacb9b commit 319d634

File tree

2 files changed

+118
-3
lines changed

2 files changed

+118
-3
lines changed

.github/workflows/macOS-build.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,26 @@ jobs:
3535
python -m pip install --upgrade pip
3636
pip install -r requirements.txt
3737
pip install py2app
38+
echo "Installed packages:"
39+
pip list
40+
41+
- name: Check tkinterdnd2 installation
42+
run: |
43+
python -c "import tkinterdnd2; print('tkinterdnd2 location:', tkinterdnd2.__file__)"
44+
python -c "import tkinterdnd2; import os; print('tkinterdnd2 contents:'); [print(f) for f in os.listdir(os.path.dirname(tkinterdnd2.__file__))]"
3845
3946
- name: Build macOS App with py2app (Alias Mode)
4047
run: |
4148
echo "Starting py2app build in alias mode for testing..."
42-
python setup.py py2app -A 2>&1 | tee build_alias.log || true
49+
python setup_py2app.py py2app -A 2>&1 | tee build_alias.log || true
4350
4451
- name: Build macOS App with py2app (Full Build)
4552
run: |
4653
echo "Starting py2app full build..."
47-
python setup.py py2app --verbose 2>&1 | tee build.log
48-
echo "Build command completed with exit code: $?"
54+
python setup_py2app.py py2app 2>&1 | tee build.log
55+
BUILD_EXIT=$?
56+
echo "Build command completed with exit code: $BUILD_EXIT"
57+
exit $BUILD_EXIT
4958
5059
- name: Verify Build
5160
run: |

setup_py2app.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
"""
2+
Custom py2app recipe for handling tkinterdnd2
3+
This ensures the native libraries are properly included in the macOS app bundle
4+
"""
5+
from setuptools import setup
6+
import os
7+
import sys
8+
from pathlib import Path
9+
import shutil
10+
11+
APP = ['main.py']
12+
13+
# Collect all resource files
14+
DATA_FILES = []
15+
res_dir = Path('res')
16+
if res_dir.exists():
17+
for root, dirs, files in os.walk(res_dir):
18+
for file in files:
19+
file_path = os.path.join(root, file)
20+
# Add to Resources folder in the app bundle
21+
DATA_FILES.append((os.path.dirname(file_path), [file_path]))
22+
23+
# Find tkinterdnd2 package and its native libraries
24+
try:
25+
import tkinterdnd2
26+
tkdnd_path = Path(tkinterdnd2.__file__).parent
27+
28+
# Add tkinterdnd2 data files
29+
for item in tkdnd_path.glob('**/*'):
30+
if item.is_file():
31+
# Include .dylib, .so, .tcl files
32+
if item.suffix in ['.dylib', '.so', '.tcl', '.tm']:
33+
rel_path = item.relative_to(tkdnd_path.parent)
34+
DATA_FILES.append((str(rel_path.parent), [str(item)]))
35+
print(f"Including tkinterdnd2 file: {item}")
36+
except ImportError:
37+
print("Warning: tkinterdnd2 not found, app may not work correctly")
38+
39+
OPTIONS = {
40+
'argv_emulation': True,
41+
'packages': [
42+
'tkinter',
43+
'PIL',
44+
'py7zr',
45+
'requests',
46+
'psutil',
47+
],
48+
'includes': [
49+
'tkinterdnd2',
50+
'tkinterdnd2.TkinterDnD',
51+
'lib',
52+
'lib.gui',
53+
'lib.gui.style',
54+
'lib.gui.context',
55+
'lib.gui.button',
56+
'lib.gui.terminal',
57+
'lib.spruce',
58+
'lib.window_manager',
59+
'lib.sd_card',
60+
'lib.usb_flasher',
61+
'lib.progress',
62+
'lib.debug',
63+
'apps',
64+
'apps.sd_flasher',
65+
'apps.sd_flasher._main',
66+
'apps.sd_flasher.events',
67+
'apps.sd_flasher.format',
68+
'apps.sd_flasher.fresh_install',
69+
'apps.sd_flasher.update_firmware',
70+
'apps.sd_flasher.update',
71+
'apps.settings',
72+
'apps.settings._main',
73+
'apps.template',
74+
'apps.template._main',
75+
'apps.template.external_functions',
76+
],
77+
'excludes': [
78+
'matplotlib',
79+
'numpy',
80+
'scipy',
81+
'pandas',
82+
'test',
83+
'tests',
84+
'unittest',
85+
],
86+
'strip': False,
87+
'optimize': 0,
88+
'compressed': False, # Don't compress for easier debugging
89+
'plist': {
90+
'CFBundleName': 'Pixel Panel',
91+
'CFBundleDisplayName': 'Pixel Panel',
92+
'CFBundleIdentifier': 'com.spruceui.pixelpanel',
93+
'CFBundleVersion': '1.0.0',
94+
'CFBundleShortVersionString': '1.0.0',
95+
'NSHighResolutionCapable': True,
96+
'LSMinimumSystemVersion': '10.13.0',
97+
},
98+
}
99+
100+
setup(
101+
name='Pixel Panel',
102+
app=APP,
103+
data_files=DATA_FILES,
104+
options={'py2app': OPTIONS},
105+
setup_requires=['py2app'],
106+
)

0 commit comments

Comments
 (0)