[Pythonmac-SIG] py2app, optimize=2, and __debug__

Kevin Watters kevinwatters at gmail.com
Wed Jul 9 15:47:41 CEST 2008

When I enable optimize=2 for our app, py2app successfully compiles all the
Python to .PYO files, but the .app it creates fails at the very first import in

With some log statements, I see that __debug__ is still True when I run the .app
-- which explains why Python will not find the standard library.  __debug__ has
to be off for Python to read PYOs.

Do I need to inject -OO into the execution of the Python process manually,
somehow?  I didn't see the right place to do it in main.c, but I'm sure there's
a way.  Has anyone else tried py2app's optimize flag?

More information about the Pythonmac-SIG mailing list