I have no way to try this locally, here is my best guess:
Try importing all the bits that you really need in the application, including exceptions that do not occur during "normal" execution
import keyring import keyring.set_password as _unused_1 import keyring.backend import keyring.backend.PasswordSetError as _unused_2
You can also require some other package at runtime to verify this, follow these steps:
$ python2.7 Python 2.7.5 (default, Sep 6 2013, 09:55:21) [GCC 4.8.1 20130725 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> before = sys.modules.keys() >>> import keyring >>> middle = sys.modules.keys() >>> keyring.set_password("a", "b", "c") Please set a password for your new keyring Password: Password (again): Please input your password for the keyring Password: >>> after = sys.modules.keys()
You see how many modules were introduced as a result of import keyring , but also a few more modules appeared as a result of keyring.set_password(...) .
Now, most of this should be automatic with py2app , but some runtime dependencies may be skipped.
The reason for this is because py2app does something complicated when it decides which modules to include. Imagine keyring.set_password() is not actually running at this point. In fact, if it and set_password should have side effects, do you expect py2app pack a simple or modified module?
source share