Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PyInstaller bundle? #19

Open
JokerQyou opened this issue Nov 20, 2014 · 9 comments
Open

Support for PyInstaller bundle? #19

JokerQyou opened this issue Nov 20, 2014 · 9 comments
Assignees

Comments

@JokerQyou
Copy link

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
Copy link
Collaborator

@JokerQyou interesting idea, please send me poc.

@jajoosam
Copy link

Any update on this @maxkrivich @JokerQyou

@JokerQyou
Copy link
Author

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
Copy link
Collaborator

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

@JokerQyou
Copy link
Author

JokerQyou commented May 26, 2018

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

  • Create a virtual environment and install pync and pyinstaller.
  • In file main.py:
# 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)
  • Produce an app bundle like this: pyinstaller -y -w --clean -n PyncPoC --osx-bundle-identifier test.debug.pync_poc main.py.
  • Run this app, and it will instantly crash.
  • Run like this to view its stdout content: dist/PyncPoC.app/Contents/MacOS/PyncPoC.

@maxkrivich
Copy link
Collaborator

@JokerQyou Thanks, I will try as soon as possible

@samuliedvin
Copy link

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

@samuliedvin
Copy link

samuliedvin commented Mar 29, 2019

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants