syabruk / pync

Python wrapper for Mac OS 10.8 Notification Center
https://pypi.org/project/pync
Other
354 stars 35 forks source link

Support for PyInstaller bundle? #19

Open JokerQyou opened 10 years ago

JokerQyou commented 10 years ago

Hi SeTeM! First of all thanks for providing this python binding of Terminal-Notifier. I found it failed within a PyInstaller bundled .app folder. And as I could not ask every end user to install terminal-notifier, I decide to pack the vendor folder into the .app bundle. But that leaded to another problem: the path of vendor folder was coded as the same level of TerminalNotifier.py file, yet TerminalNotifier.py would be bundled into a .pyz archive file. If this could be solved I'd be very much appreciated.

maxkrivich commented 6 years ago

@JokerQyou interesting idea, please send me poc.

jajoosam commented 6 years ago

Any update on this @maxkrivich @JokerQyou

JokerQyou commented 6 years ago

Hmmm, I wonder how I missed the last notification from this thread. I'll take a look and try to reproduce it this weekend. I'll post my progress here.

maxkrivich commented 6 years ago

@JokerQyou @jajoosam thank you, I will be waiting for any updates from you.

JokerQyou commented 6 years ago

Okay. This is easier to reproduce than I thought. Basically it's like this:

# coding: utf-8
import time

import pync

if __name__ == '__main__':
    pync.notify('Hello World', title='PyInstaller')
    time.sleep(3)
    pync.notify('About to quit')
    time.sleep(1)
maxkrivich commented 6 years ago

@JokerQyou Thanks, I will try as soon as possible

samuliedvin commented 5 years ago

This would be great if there's a fix or some workaround, any update on this? @maxkrivich @JokerQyou

samuliedvin commented 5 years ago

I kinda found a workaround for this problem by putting the pync folder into my resources folder, which are then bundled into the app.app/Contents/MacOS folder. Because pync is searching for the terminal-notifier.app from the folder its been called (os.path.dirname(file) == /path/to/app.app/Contents/MacOS/pync, this works for me now.

self.app_path = os.path.join(
    os.path.dirname(__file__),
    "vendor/terminal-notifier-%s/terminal-notifier.app" % self.TERMINAL_NOTIFIER_VERSION
)
self.bin_path = os.path.join(self.app_path, "Contents/MacOS/terminal-notifier")

So in the resulting app bundle the terminal-notifier.app should be found in /path/to/app.app/Contents/MacOS/pync/vendor/terminal-notifier-2.0.0/terminal-notifier.app.

JokerQyou commented 5 years ago

This issue was created so long ago that it's very hard to recall the context of the specific project involved. I end up calling macOS notification API directly via objc module. Some basic code could be found here.