
Creating standalone Mac OS X applications with Python and py2app - ingve
https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/
======
Loic
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/](http://www.pyinstaller.org/)

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

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

~~~
makecheck
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. :)

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

------
subnaught
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](https://github.com/jaredks/rumps)

~~~
metachris
Thanks, added a link to the post!

------
legulere
If I see correctly this is using python 2?

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

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

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

~~~
mmastrac
No idea why you are getting downvoted -- Slack for OSX is built on Electron
AFAIK. [http://electron.atom.io/](http://electron.atom.io/)

