pythonexepyinstaller

Is there a way to bundle an external .exe dependency (ffmpeg.exe) into pyinstaller's .exe?


I'm trying to create an audio manipulation utility which uses ffmpeg.exe in one of the python packages through python system pipeline. The ffmpeg file is in my local project.

I've read that you can bundle DLLs and other data files like images or text, but haven't seen a solution for this.

The optimal solution would be that no installer would be needed and you could run the utility from cmd without any dependency - this includes having ffmpeg pre-installed.

Is there a way to bundle ffmpeg.exe into the .exe file which is created by pyinstaller or maybe there's another solution?


Solution

  • You can actually package .exe files (and any other types of files - from the pyinstaller docs I could understand that only .dlls and such can be bundled like this, thus this question) into the executable using the "binaries" option in the pyinstaller's .spec file like:

    binaries=[('.\\prerequisites\\', 'prerequisites')],
    

    In this case, when using the --onefile or -F parameter, the "prerequisites" folder's contents from the .spec file location are packed into the .exe and upon executing it, they are unpacked into the temporary MEIxxxx folder into a folder named "prerequisites". The executable can communicate with the files located there.