How to manually include DLL from Python package (e.g. FFmpeg in OpenCV)
See original GitHub issueI am using Python 3.8.11 (through Anaconda) on Windows, with packages (installed with pip, not conda):
Nuitka==0.6.17.2
numpy==1.21.1
opencv-python==4.5.3.56
I am using --plugin-enable=numpy --plugin-enable=anti-bloat
to enable use of numpy
, which is a dependancy of OpenCV for Python.
opencv-python
includes a build of FFmpeg as a dll. The exact file name depends on the version of FFmpeg, which in turn depends on the version of opencv-python
; in this version particular it is:
<conda-env>\Lib\site-packages\cv2\opencv_videoio_ffmpeg453_64.dll
It isn’t found by the dependency walker. But this is to be expected because it’s loaded dynamically only when needed, with a graceful failure (e.g. VideoWriter
will throw a Python exception). This is done as part of satisfying the LGPL requirements of FFmpeg.
This is more a question than a bug report: what command line option (if any) could I use to include this file?
- I considered (and tried!)
--include-plugin-files=
but it seems to be for Python files to be compiled - I considered
--include-data-file=
but it takes a file system path, not a path relative to the Python environment - I considered
--include-package-data=
but it specifically says it excludes DLLs.
For now I am using --include-data-file=%CONDA_PREFIX%\Lib\site-packages\cv2\opencv_videoio_ffmpeg453_64.dll=opencv_videoio_ffmpeg453_64.dll
and it works (e.g. I can use VideoWriter
) but it’s a bit fragile as it assumes that I’m using Anaconda and Windows (although that is likely to usually be true for me) and the specific FFmpeg number will change as OpenCV version changes.
(Off topic: Many thanks for all your hard work on Nuitka 😄)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
The said work is complete and will be in 0.6.18, so this is next on the agenda.
This is the next one right after static optimization for
importlib.import_module
is complete, which itself will take some time. Feel free to remind me when I make a release that claims to do it, but only then.