3

I need to make some modifications to scikit-learn, including changes to the cython code.

I haven't worked on cython before, so could do with some guidance - so far I have got all the dependencies going in a python virtualenv, and cloned and installed the sklearn git.

Now, what is a good workflow for modifying the .pyx files? Should I make modifications and then reinstall to see the effects? Or build instead?

Is there any way to avoid recompiling all the stuff that is unchanged?

I have heard of import pyximport; pyximport.install() but for me this throws a compile error with sklearn -> is there a way to ensure it uses the same options as the Makefile which runs successfully?

In general I am looking for guidance on how to modify a large cython project without spending decades waiting for unmodified files to recompile.

N. McA.
  • 4,796
  • 4
  • 35
  • 60

1 Answers1

3

You could simply run,

python setup.py develop

after each modification. Unlike the install command this will not copy any files and only creates a symbolic link to the working directory. It will also automatically build all the necessary extensions in place, in an equivalent of

python setup.py build_ext --inplace

If you change a Cython file in your project, only those files will be recompiled next time you run the develop command.

The pyximport module is nice for standalone Cython functions. However, for a more complex project, with multiple files, the above approach would probably be simpler.

rth
  • 10,680
  • 7
  • 53
  • 77