Instruct PyInstaller to include Python built-in `help()` facility

58 views
Skip to first unread message

Michael Leonard

unread,
Aug 10, 2021, 2:51:22 AM8/10/21
to PyInstaller
Hi all,

I have searched the internet off and on for a few years without luck trying to find an answer to this question. Is it possible to instruct PyInstaller to ship with Python's built in help() tool and not strip that out?

My tool provides both a CLI and GUI REPL which provides users with access to the tool's internals. The classes/functions/methods within the tool are fairly well documented for the most part, but because my users cannot call the built in `help()` function on anything I usually resort to just telling them to download the source files as reference.

For example of what I am talking about, here is a snippet from the REPL, showing how I am able to get help on a function when I'm using the 'development' version of my tool, which runs on pure Python:
Screen Shot 2021-08-09 at 18.31.56.png
However, attempting the same thing with the 'packaged' version of the tool shows the following error:
Screen Shot 2021-08-09 at 18.34.06.png
Is it possible to tell Pyinstaller to keep the Python help function?

Thanks,
Michael

Jasper Harrison

unread,
Aug 10, 2021, 3:11:08 AM8/10/21
to pyins...@googlegroups.com
Not currently, no, though if you open a feature request on the GitHub repository I don't see a reason we couldn't add a flag of some kind to not strip it out.

Jasper Harrison

Core Developer on PyInstaller


-------- Original Message --------
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/43efce1c-e6ba-4ce5-b4c5-4a1fc5bb4805n%40googlegroups.com.

Eric Fahlgren

unread,
Aug 10, 2021, 1:56:17 PM8/10/21
to pyins...@googlegroups.com
Could a workaround be as simple as just adding an explicit reference to the REPL help?

from _sitebuiltins import _Helper
globals()['help'] = _Helper()

Would this survive processing through pyinstaller?

Michael Leonard

unread,
Aug 10, 2021, 2:46:53 PM8/10/21
to PyInstaller
Hi Eric, that seems like a good suggestion, I will give it a try the next chance I get to package the tool, should be towards the end of this week.

Michael Leonard

unread,
Aug 27, 2021, 5:15:45 AM8/27/21
to PyInstaller
Thanks for the help all,

Eric's suggestion led me down a known good path. Following `from _sitebuiltins import _Helper` led me to the fact that this is basically just importing `pydoc` and that the `help` function is `pydoc.help` method. So I added `pydoc` to the `hiddenimports` list in PyInstaller Analysis, and then injected the `pydoc.help` method into the CLI/REPL as `help` methods. This is working well for me in the packaged tool.

Reply all
Reply to author
Forward
0 new messages