A way to include all standard library modules

18 views
Skip to first unread message

Dmitry Meyer

unread,
Dec 2, 2020, 9:04:52 AM12/2/20
to PyInstaller
I'm trying to bundle an application that is extendable via plugins. The plugins are regular Python modules. The problem is that these plugins may import any module from the standard library (third-party modules imports are not a problem, they are not allowed by plugin guidelines).

Is it possible to unconditionally include all of the standard library modules?

I can use some third-party library providing a list of standard library modules (https://github.com/jackmaney/python-stdlib-list , for example) and include all of them as hiddenimports, but I am looking for more elegant solution.

un.def

unread,
Dec 2, 2020, 9:05:07 AM12/2/20
to pyins...@googlegroups.com
I am trying to bundle an application that is extendable via plugins. The plugins are regular Python modules. The problem is that these plugins may import any module from the standard library (third-party modules imports are not a problem, they are not allowed by plugin guidelines).
 
Is it possible to unconditionally include all of the standard library modules?
 
I can get a list of all of the standard library modules from some third-party library (https://github.com/jackmaney/python-stdlib-list, for example) and include each module as a hidden import, but I am looking for a more elegant solution.
 
 

bwoodsend

unread,
Dec 2, 2020, 4:12:20 PM12/2/20
to PyInstaller

There’s no distinction between builtin and 3rd party libraries to PyInstaller so you won’t find an --include-standard-lib option. That python-stdlib-list sounds like a sensible option. All you’d need to so is edit the .spec file: put from stdlib_list import stdlib_list at the top and replace hiddenimports=[], with hiddenimports=stdlib_list("3.7"), (or whatever your Python version is. That would mean you wouldn’t need to include or run stdlib_list in the executable itself.

un.def

unread,
Dec 2, 2020, 4:34:34 PM12/2/20
to pyins...@googlegroups.com
Thanks for the detailed answer!
Reply all
Reply to author
Forward
0 new messages