[IPython-dev] Sage customizations
Jason Grout
jason-sage at creativetrax.com
Tue Sep 11 17:24:03 EDT 2012
Fernando recently posted that we should be able to do the Sage
customizations to ipython via just config changes and extensions. As
I'm getting deeper into what we do, I see the following obstacles.
Should we be able to do these changes from config changes and extensions?
* interactiveshell system_raw function: Sage messes with the
LD_LIBRARY_PATH so that programs included in Sage work correctly.
However, if we're calling out to a system program installed outside of
Sage, we need to reset the LD_LIBRARY_PATH. So right now we override
system_raw to set the correct LD_LIBRARY_PATH if we don't recognize the
command as a sage-provided command. What if we could have pre- and
post- system_raw hooks, where we could run these commands? I can
imagine that these would also be useful if you wanted to always set a
current directory for raw system commands, etc. I suppose the same
issue applies to the system_piped command.
* SageTerminalApp inherits from TerminalIPythonApp and overrides the
crash handler to print out custom text for reporting crashes to Sage.
Is there a way to get the app, given the shell? If there was, I could
override this as part of an extension, but I'm not sure if that's the
most elegant way to do things. Having a SageTerminalApp also lets us
set the name to be "Sage", and just seems more natural in some ways.
Here are several sticky points that seem like they should be easier (or
at least less controversial) to solve
* transformations are stateless (they only depend on a single line, and
shouldn't store state) --- what is the rationale behind this? For
example, we'd like to do a dedenting transformation (useful if we are
pasting lots of text, after we turn off autoindenting, or even if we are
pasting a lot of single commands with autoindenting). Of course, to do
a dedenting transformation, we need to know the indentation of the first
line, so it is not stateless. Looking at the IPython code, it would be
trivial to pass the line number in with the line string to transformations.
* oinspect -- we need to monkey-patch ipython to replace these functions:
IPython.core.oinspect.getdoc = sageinspect.sage_getdoc
IPython.core.oinspect.getsource = sagedoc.my_getsource
IPython.core.oinspect.getargspec = sageinspect.sage_getargspec
because these functions are explicitly imported and used in various
places in IPython. Rather, could IPython use, say, something tied to an
inspector object attached to the shell or something? Then we could just
set those attributes.
Comments are welcome! I'm willing to help with pull requests for any of
the items above that you guys are okay with changing.
Thanks,
Jason
More information about the IPython-dev
mailing list