Search code examples
pythonaws-lambdapython-poetrypython-wheel

embed binary file in python wheel package


==Context==

I'm building a python package that is going to be installed and used inside an AWS container lambda. My package is built using poetry and deployed in a self-managed python package index.

One of my lambda dependency is imageio-ffmpeg, which surprisingly to me embed the ffmpeg binary see here, the result is that I can use ffmpeg without having to install it on the system myself, I only need to install the python package using pip.

==The problem==

My new package is using ffmpeg and ffprobe, but ffprobe is not installed in my aws lambda context, I would like to reproduce the behavior of imageio-ffmpeg and embed the ffprobe binary in my package.

I've tried adding a binary folder like imageio-ffmpeg but the binary files are not made available by my package. I suppose the wheel doesn't contain the required information about these binaries. I can't find documentation or resources about how this work or how this can be done.


Solution

  • Looking more closely into the code of imageio-ffmpeg I realised it was dynamically getting the path to its binary at runtime if none was available system wide. I did the same and it works like a charm.