Packaging app on OS X using py2app

99 views
Skip to first unread message

Kevin Ollivier

unread,
Jan 31, 2017, 11:39:35 PM1/31/17
to CEF Python

I am packaging up an app using CEFPython on OS X using py2app, but I'm getting a crash during the Initialize call. I specify cefpython3 as a package to py2app, which causes it to copy the entire cefpython3 folder into the app's Resources/lib/python2.7 directory, the same dir as site-packages.zip.


Googling the problem, i found some reports that suggest that the issue could be with finding the locale files, which are in the Resources subdir of the package. I tried copying those files into the app's main Resources folder, but it did not have any effect.


Are the resources supposed to go in some other folder, or do I need to put the dylibs in the Framework folder, or somewhere else? Has anyone succeeded in wrapping cefpython3 into an OS X app before?


Any general advice on how to debug this problem or get more info without crashing would be appreciated as well. :)


Thanks,


Kevin

dwi...@gmail.com

unread,
Feb 1, 2017, 2:18:40 AM2/1/17
to CEF Python
Perhaps you can see other topic here :
https://groups.google.com/forum/#!topic/cefpython/ZCQWjutERHc


I used the pyinstaller packager . My bundle crashed so many times using the py2app and it was a painful effort and lots of experimental technique ;->

Kevin Ollivier

unread,
Feb 1, 2017, 1:42:52 PM2/1/17
to CEF Python
Thanks! Using that info I was able to get it to work with py2app without any issues. All I really needed to do was to add cefpython to packages in setup.py, to ensure everything got copied into the app, then add the following lines before initializing CEFPython:

    if hasattr(sys, 'frozen') and 'darwin' in sys.platform:
        cef_dir = os.path.join(os.getcwd(), "lib", "python2.7", "cefpython3")
        settings["resources_dir_path"] = os.path.join(cef_dir, "Resources")
        settings["browser_subprocess_path"] = os.path.join(cef_dir, "subprocess")
        settings["locale_pak"] = os.path.join(cef_dir, "Resources", "en.lproj", "locale.pak")

I suspect the reason you were getting multiple app icons was that you were copying things into Contents/MacOS, which the app bundle expects will only contain the app's executable. I'm guessing the multiple app icons were caused by OS X somehow thinking of each call to subprocess as starting a new instance of your app. I used a Python.org 2.7.11 build, and I'm running on OS X 10.11.

If possible, it might be good to have these settings as default for frozen apps on OS X. Definitely myapp.app/Contents/MacOS is not the right place to be looking for resources, and somehow cefpython doesn't look there when running from Python.app.
Reply all
Reply to author
Forward
0 new messages