[Cython] Move IPython's cython extension to cython

Stefan Behnel stefan_ml at behnel.de
Sun Apr 6 09:18:05 CEST 2014


Martín Gaitán, 06.04.2014 06:24:
> On Sun, Apr 6, 2014 at 12:37 AM, Robert Bradshaw wrote:
>> I'd say this could generally make sense. Would it be the case that iff
>> cython is installed then the %cython magic would be available and just
>> work?
> 
> Yes, but before to use it, you'll need to load the extension somewhere.
> Could be with ipython's %load_ext or setting up it in your config script to
> be loaded automatically on the startup.
> 
> For example, see how octave magic (included in the package oct2py) works
> 
> http://nbviewer.ipython.org/github/blink1073/oct2py/blob/master/example/octavemagic_extension.ipynb?create=1
> 
> and here is the code
> https://github.com/blink1073/oct2py/tree/master/oct2py/ipython

Would it be ok to expose the "load_ipython_extension()" function directly
on the Cython package? Then you'd just say "%load_ext Cython". I suggest to
drop the implementation into Cython/Build/IPythonMagic.py and import it
from there inside of "load_ipython_extension()". There is a "Tests" package
in there as well.

It's also likely that the implementation could benefit from a refactoring
within that package to avoid code duplication.


>> Also, how testable is this (e.g. via automated tests vs. having
>> to fire up a notebook and test it manually)?
> 
> There is some unittests
> 
> https://github.com/ipython/ipython/blob/master/IPython/extensions/tests/test_cythonmagic.py
> 
> Of course, they could/should be included in the moving. I could refactor
> them to remove Nose as a requirement, but obviously IPython (probably few
> versions) would be mandatory to run them.

Yes, getting rid of nosetest looks simple enough. We have our own test
runner in runtests.py that also runs unit tests.

We could install IPython on our CI server to run the tests there, so I
don't see a problem with it (as long as the tests do *not* run if IPython
is not available, e.g. on Travis).

Stefan



More information about the cython-devel mailing list