Excluding matplotlib backends from py2app
<p>I'm using <code>py2app</code> to make a <code>wxPython</code> frozen binary that uses <code>matplotlib</code> (whew).  The resulting executable is quite large, so I'd like to whittle it down if possible.</p>

<p>One obvious way of doing this is to exclude unneeded <code>matplotlib</code> backends.  I've tried running my script with <code>python setup.py py2app --matplotlib-backends -</code> which should compile only backends that are used in the script, as documented here: <a href="https://pythonhosted.org/py2app/options.html" rel="nofollow">https://pythonhosted.org/py2app/options.html</a>.  The resulting executable is indeed a lot smaller, but it's broken.  I also tried <code>python setup.py py2app --matplotlib-backends "WXAgg"</code> which failed the same way.  Here is most of the traceback (awkwardly copied from Console, sorry).  </p>

<pre><code>import wx

File "wx/__init__.pyc", line 45, in &lt;module&gt;

File "wx/_core.pyc", line 4, in &lt;module&gt;

File "wx/_core_.pyc", line 14, in &lt;module&gt;

File "wx/_core_.pyc", line 10, in __load

ImportError: dlopen(/Users/***/***/***/dist/magic_gui.app/Contents/Resources/lib/python2.7/lib-dynload/wx/_core_.so, 2): Library not loaded: @rpath/lib/libwx_osx_cocoau-3.0.dylib

Referenced from: /Users/***/***/***/dist/magic_gui.app/Contents/Resources/lib/python2.7/lib-dynload/wx/_core_.so

Reason: image not found
</code></pre>

<p>Maybe I can explicitly tell it to include libwx_osx_cocoau-3.0.dylib.  Or, maybe I need to explicitly include another backend (although I am using <code>wxPython</code>, so the WXAgg backend should be right).</p>

<p>I have two questions: first, is there a way I can include only required <code>matplotlib</code> backends without breaking my program?  Second, are there other ways I could/should consider to make my program smaller with py2app?</p>