Fallback to pydoc if site._Helper is not defined #2606

Open
eudoxos opened this Issue Nov 19, 2012 · 3 comments

Projects

None yet

5 participants

@eudoxos

ipython uses site._Helper as help() function. In some cases (specifically, when running in frozen pyInstaller setup), site.py is not have the same implementation as the one shipped with cpython. Since site._Helper is an internal function (leading underscore), there should be a fallback in case of ImporrError implementing site._Helper locally (http://hg.python.org/cpython/file/cf606c403f14/Lib/site.py#l445)

@durden

The workaround that exists for this doesn't completely work. The current workaround doesn't provide the built-in help function that site.py does. The fake-site.py does provide a minimal _Helper class. However, the real site.py also sets builtins.help = _Helper. So, using the IPython shell inside of something that was built with PyInstaller doesn't work.

Are there any problems with adding the following to the fake-site.py?

try:
    import __builtin__ as builtins
except ImportError:
    import builtins

builtins.help = _Helper()

I've successfully tested the above code with my scenario. However, I don't know enough about PyInstaller as a whole to know if it could cause issues elsewhere.

@minrk minrk removed the prio-low label Jan 14, 2015
@Carreau Carreau added sprint-friendly and removed quickfix labels Jun 12, 2015
@htgoebel

This should be solved on ipyhton's side. If we include pydoc in our fake-site-module, pydoc will be included in every frozen app. And pydoc imports Tkinter, thus adding another huge pile of software to every frozen app.

@htgoebel

If you'd accept a pull-request following the idea of the first comment, I'll prepare one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment