Embedding Python in a MacOS Application

Embedding a python application in a MacOS cocoa application via pyinstaller

Dean Liu
Dean Liu
Feb 25, 2017 · 4 min read
Image for post
Image for post
Mosaic Shapes for macOS uses Python
guppy:~ dean$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
guppy:~ dean$ python -version
Python 2.7.13
mkvirtualenv -python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python
python pyinstaller.py run.py -icon=icon-windowed.icns -clean -windowed -onefile -osx-bundle-identifier "com.mosaic.mosaicshapes"
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
guppy:~ dean$ cat ~/Desktop/p.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
guppy:~ dean$ cat ~/Desktop/c.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>
</dict>
</plist>

Python Pandemonium

A place to read and write about all things Python.

Dean Liu

Written by

Dean Liu

Engineer at Lyft. My thoughts are my own.

Python Pandemonium

A place to read and write about all things Python. If you want to become a writer for this publication then let me know.

Dean Liu

Written by

Dean Liu

Engineer at Lyft. My thoughts are my own.

Python Pandemonium

A place to read and write about all things Python. If you want to become a writer for this publication then let me know.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store