I can't get py2app to add all needed libraries for distribution

Viewed 227

I am trying to produce a standalone Mac app for distribution from a working python script using py2app. I am able to launch and run the bundled app on my computer, but when I try to run the bundled app on another computer I get the error message (when opening it up for debugging to see the problem in the terminal):

ImportError: dlopen(/Applications/BirdHouse.app/Contents/Resources/lib/python3.9/lib-dynload/_ctypes.so, 0x0002): Library not loaded: @rpath/libffi.7.dylib
  Referenced from: /Applications/BirdHouse.app/Contents/Resources/lib/python3.9/lib-dynload/_ctypes.so

and then it gives a long list of where it's searching, including within the app I produced and in paths that are given by where the library is on my machine.

My python project is very simple; other than what comes with standard python (3.9) it only uses two packages, tk and tksheets. libffi is a standard python library and so it seems reasonable that something needs it.

Having looked at as many websites as I can about this, I have tried tweaking the setup.py by adding various things to the options dict, including (each line individually, not all at once):

'packages': ['libffi']
'resources': ['libffi']
'resources': ['/opt/anaconda3/envs/ExpManBuildEnv/lib/libffi.7.dylib']
'resources': [('lib', ['/opt/anaconda3/envs/ExpManBuildEnv/lib/libffi.7.dylib'])]
'packages': ['libffi-3.3-hb1e8313_2'],

(The paths /opt/anaconda3/envs/ExpManBuildEnv/lib are where the relevant libraries are on my machine.) None of them fix the problem, or in fact seem to have any impact on the process.

I have to believe this is a simple problem to resolve, since 1) a major purpose of py2app is specifically to bundle up all needed libraries; and 2) there are lots of comments on the web (including in the py2app documentation) to the effect that this type of problem arises often and can be handled by using --includes or --packages. I just can't figure out how to make it work.

Any suggestions?

0 Answers
Related