title: py2app: how to include modules that will be loaded by __import__?
body: <p>I have a Python application that loads python modules dynamically at run time (using <code>__import__</code>). The modules to load are in a package called '<code>plugins</code>' (i.e. subfolder called <code>plugins</code> with <code>__init__.py</code> etc). All works fine running from the python interpreter, and even when compiled to a windows binary using py2exe.</p>
  
  <p>I tried building a OSX app from it, which succeeded, but when running the .app I get an ImportError: '<code>no module named plugins.xxxx</code>'.</p>
  
  <p>I am pretty sure I gave the correct options to py2app (<code>'includes': [...]</code>, <code>'packages':['plugins']</code>, identical to what I do for py2exe), since when I browse the .app content, I see all the plugin modules in a folder <code>Contents/Resources/lib/python2.5/plugins/</code>. </p>
  
  <p>So, why can't the app find my modules (must be some path issue)?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I've found a way to make it work, but it isn't a good solution:
  When I printed the paths Python searches for modules (using <code>print sys.path</code>), I noticed that the folder <code>Contents/Resources/lib/python2.5/plugins/</code> was NOT listed. However, the folder <code>Contents/Resources/</code> is, so I moved the <code>plugins</code> folder to the <code>Contents/Resources</code> folder. Now the plugins are found. But I am still not happy with this ugly, manual hack.</p>