Post

Replies

Boosts

Views

Activity

Linking against Python shared library to make distribution
Hi there, I want to build an application that can be run on different macos machines. That app uses libpython3.11.dylib. It could not be just linked with libpython because in out binary path to library may be different: /System/Library/Frameworks/Python.framework/... /usr/local/Cellar/python/3.X.Y/Frameworks/Python.framework/Versions/... /Library/Frameworks/Python.framework/Versions/... $(pyenv root)/versions/{VERSION} .... I need to ensure that the application uses the Python library corresponding to the Python version that the user is using. Attempted to make a workaround by creating a symlink to the current library and setting the library path to @executable_path/../lib/libpython3.11.dylib, but it did not work. Here's the error I encountered: % /Users/user/Downloads/xtensa-esp-elf-gdb/bin/xtensa-esp-elf-gdb-3.11 dyld[92502]: Library not loaded: @executable_path/../lib/libpython3.11.dylib Referenced from: <F6F408DC-F698-3545-9C75-82486ADA77BE> /Users/user/Downloads/xtensa-esp-elf-gdb/bin/xtensa-esp-elf-gdb-3.11 Reason: tried: '/Users/user/Downloads/xtensa-esp-elf-gdb/lib/libpython3.11.dylib' (code signature in <666A28FE-7CD3-384C-A727-7DE3D98625A2> '/Library/Frameworks/Python.framework/Versions/3.11/Python' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/System/Volumes/Preboot/Cryptexes/OS@executable_path/../lib/libpython3.11.dylib' (no such file), '/Users/user/Downloads/xtensa-esp-elf-gdb/lib/libpython3.11.dylib' (code signature in <666A28FE-7CD3-384C-A727-7DE3D98625A2> '/Library/Frameworks/Python.framework/Versions/3.11/Python' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/usr/lib/libpython3.11.dylib' (no such file, not in dyld cache) zsh: abort I cannot distribute libpython within the application because it requires Python modules. Moreover, the application should use Python modules that are installed on the user's system. What can I do to make this work properly? E.g. user have pythons installed: /usr/local/Cellar/python/3.11.3/Frameworks/Python.framework/Versions/3.11... /Library/Frameworks/Python.framework/Versions/3.11/... Obviously, the user has only one active Python from this list. How can my application use the correct libpython?
14
0
1.4k
Oct ’23