|
| 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