We are building an application that dynamically imports other Python and runs it. We don't know ahead of time what modules those other Python files might need, but these other Python files should be able to rely on having all built-in modules available.
Because of how PyInstaller's analysis works, we are losing a lot of built-in modules if our main application isn't using them.
Is there a way to force PyInstaller to include everything in Lib (not site-packages)?
Note: we have considered building up a list of hidden imports, but:
There is third-party module stdlib_list
that has all the modules in the Lib. It also includes built-in modules. Use it from the PyInstaller's hook for main/any module of your app:
import stdlib_list
hiddenimports = list(stdlib_list.stdlib_list())
My research shows that there is no built-in way to list standard modules from polluted environment. I suppose that's the reason for PyInstaller no having an easy option to include Standard Lib.