Hacker News new | past | comments | ask | show | jobs | submit login
Creating standalone Mac OS X applications with Python and py2app (metachris.com)
108 points by ingve on Nov 29, 2015 | hide | past | favorite | 14 comments



If you want to package your Python application, you should really take a look at PyInstaller[0]. I have been using it for years with great success.

[0]: http://www.pyinstaller.org/


How does this package layout interface with code signing and bundle IDs?

My main project uses a custom-setup ".app" bundle on Mac OS X (combining both a pure Python front-end and C++ bindings) and I've found that it does require a bit of care to see correct behavior.

For instance I found that El Capitán seems to really hate symbolic links now and will consider a code-sign tainted if there is an outside symbolic link (at least, for certain link destinations?).

And I found, at least on older Mac versions, that system calls would sometimes think my application was Python and assume the Python bundle ID instead of my own, if I simply ran Python itself. Whereas, after I included a built binary directly in the MacOS folder that essentially says "int main(int argc, char* argv[]) { return Py_Main(argc, argv); }", it was fine.

I wanted to run the system Python by reference and not bloat my executable; the call-Py_Main() approach worked well for that, too.


Thanks for the thought!

I haven't tried it, but this post [1] describes a project that got everything to work with the Mac App Store.

[1] http://dafoster.net/articles/2014/06/24/submitting-a-python-...


Do you happen to have a repo for this app you speak of? Would love to take a look!


Yep. :) It's "MacTerm":

    https://github.com/kmgrant/macterm
The Python front-end is mostly here:

    https://github.com/kmgrant/macterm/tree/master/Build/Application/PythonCode
The ".app" bundle layout is constructed as part of the build:

    https://github.com/kmgrant/macterm/blob/master/Build/GNUmakefile
...but basically it puts Python scripts and a Python-runner into "MacOS", and Python and C++ libraries into "Frameworks". You could also download the built ".app" to see the final layout.

This is actually quite a bit simpler than it used to be. In the old days I was able to support both PowerPC and Intel, multiple versions of Python and about 6 different old Mac OS X versions in the same bundle. I still can't quite believe that it worked. :)


Awesome! Thanks for sharing, will definitely dig through this. :)


This looks great. There is also rumps[0] if you just need to create a status bar app from Python code.

[0]: https://github.com/jaredks/rumps


Thanks, added a link to the post!


If I see correctly this is using python 2?


Yup, has a `from __future__ import print_function` in one of the examples in the bitbucket repository.


py2app has experimental support for Python 3. I've just tested it with a simple Python 3 tkinter interface and it works just fine!


Just a reminder that this is a wrapper for the python app and not a compiler, hence someone can easily dig through the app and get your Python code.


Is Slack's desktop app just a container for web-based technologies?

Is it's iOS app pure native or is it also built with web technologies?


No idea why you are getting downvoted -- Slack for OSX is built on Electron AFAIK. http://electron.atom.io/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: