How To Use Ctypes.util.find_library To Import .so Libraries In Aws Lambda (python)?
Solution 1:
Tested on Python:3.7 AWS lambda environment:
You need to add liblept.so (just rename liblept.so.5) to the /lib folder of your lambda package or in /opt/lib of your layer. The file must be called liblept.so because find_library only looks for ".so" files, not ".so.5" files:
From the python doc: https://docs.python.org/3/library/ctypes.html
ctypes.util.find_library(name)
Tryto find a library andreturn a pathname. name is the library name without any prefix likelib, suffix like .so, .dylib or version number (this is the form used for the posix linker option -l). If no library can be found, returns None.
When only adding "liblept.so", the linker complains that it cannot find "liblept.so.5", so I also added "liblept.so.5" to the lib folder.
Maybe someone else can pitch in and find a solution that does not use a duplicate file.
AWS lambda will automatically make any file in /opt/lib or /lib available via LD_LIBRARY_PATH.
On Python 3.8 you may also need to include ld and objdump, as per this thread: https://forums.aws.amazon.com/thread.jspa?threadID=313506, altough I have not tested that.
Post a Comment for "How To Use Ctypes.util.find_library To Import .so Libraries In Aws Lambda (python)?"