[IPython-dev] Cell magics and extensions

Brian Granger ellisonbg at gmail.com
Thu Jun 7 17:37:19 EDT 2012

[let's discuss and decide about this soon as it affects multiple PRs in flight]

This is a good topic, thanks for bringing it up.  Fernando and I
talked about this briefly the other day and had the following

* At least getting started, I think we can err on the side of putting
cell magics in IPython/extensions.
* In the long run, our policy should be two fold:
  - We should ship cell magics that a good fraction of IPython's users
will use.  So things like cythonmagic, shell, file, or sympyprinting
definitely makes sense.  Not sure if the dot or heirarchy ones make
sense.  One pro of having them in IPython is that our test machinery
makes it easy to write tests for them.
  - When it makes sense, we should encourage third part projects to
ship IPython extensions with the magics for their project.  So it
would *completely* make sense for sympy to ship sympyprinting and for
cython to ship cythonmagic.  One pro for having these outside IPython
is that we don't have to manage an ever growing list of exclusions in
* There is absolutely no reason whatsoever that extensions need to be
installed into the IPython source tree.  They are perfectly valid
python packages that can be loaded using the following syntax:

%load_ext sympy.magics

This way the 3rd party projects and put the extension where-ever they
want and keep it in sync with their code base.  Copying them into
IPython/extensions is just asking for problems as we would become a
mini site-packages.  The only case where I can see %install_ext making
sense is for simple magics that have no upstream Python project to
bundle with.  This raises other questions:

* Where should users host standalone magics?  Should we create a
separate repo?  Gists?  Let the user decide?



On Wed, Jun 6, 2012 at 5:26 PM, Thomas Kluyver <takowl at gmail.com> wrote:
> A recent pull request for a graphviz %%dot cell magic [1] brings up
> some questions about our scope.
> What range of extensions do we envisage shipping with IPython?
> Obviously there's a lot of possibilities for the new cell magics, but
> in my opinion the benefit of an extension system is that things like
> this can live outside the main repository and be installed separately.
> What more can we do for third party extensions? As a minimum, I think
> we should have a list of available extensions, perhaps on
> wiki.ipython.org .
> We can easily install extensions inside IPython with the %install_ext
> magic. Should we make it easier to install extensions outside IPython
> - e.g. by finding a way to register them on PyPI and install them with
> pip? Further ahead, if there are important extensions, would it be
> easy for distributions to package them?
> [1] https://github.com/ipython/ipython/pull/1854
> Thanks,
> Thomas
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com

More information about the IPython-dev mailing list