Error when making Python app with py2app

Hi all,


I am trying to create a standalone Mac OS X application with Python (py2app) using an example code, which worked on Yosemite.

On El Capitan Beta 1 and Beta 2, no minimal demo app seems to work any longer.


# python setup.py py2app -A

running py2app

creating /Users/bluedot/build/bdist.macosx-10.11-intel/python2.7-standalone/app

creating /Users/bluedot/build/bdist.macosx-10.11-intel/python2.7-standalone/app/collect

creating /Users/bluedot/build/bdist.macosx-10.11-intel/python2.7-standalone/app/temp

creating build/bdist.macosx-10.11-intel/python2.7-standalone/app/lib-dynload

creating build/bdist.macosx-10.11-intel/python2.7-standalone/app/Frameworks

*** creating application bundle: MyApp ***

error: /Users/bluedot/dist/MyApp.app/Contents/MacOS/MyApp: Operation not permitted


setup.py:

from setuptools import setup


APP = ['MyApp.py']

DATA_FILES = []

py2app_options=dict()


setup(

app=APP,

data_files=DATA_FILES,

options=dict(py2app=py2app_options),

setup_requires=['py2app'],

)


MyApp.py:

# Just empty dummy file

Is py2app still fully supported in out-of-the-box Mac OS X El Capitan installation?

Replies

I have also just tried to make a simple app using py2app and have the same error.

Still the same issue with py2app in Beta 4 (15A226f).

Binary being generated by py2app as <App_Name>/Contents/MacOS/<App_Name> is forbidden to write file attributes (like last access time, utime, chflags) by the sandboxd. That is the place where the app build fails.


When SIP mode (rootless) is switched-off then py2app works. However, most people won't to disable SIP.

Unbelievably this is still broken in the released version of El Capitan. This reply is for the benefit of anyone else who finds this thread whilst trying to get py2app working again on OS X.


It appears it isn't sufficient just to disable SIP to fix py2app unless you build your bundles as root. To build as a normal non-root user, you also need to use 'chflags -R norestricted /System/Library/Frameworks/Python.framework' to remove the restricted file flag on the system Python installation. (It's probably sufficient to remove it from one particular file within that bundle directory, but I didn't investigate further. Perhaps py2app is trying to preserve the flags on a file copied from the bundle?)


I've reported the bug as 22966601 with a recipe to reproduce it, but this may duplicate reports by earlier posters in this thread.

This broke for me as well. Is there a way to get this to build?