Workflow for modifying large cython projects

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

I haven't worked on cython before, so might make some recommendations - so far I have all the dependencies happening in the python virtual environment and cloned and installed by sklearn git.

Now, what's a good workflow for modifying .pyx files? Do I have to make changes and then reinstall to see the effects? Or create instead?

Is there a way to avoid recompiling everything that hasn't changed?

I heard about import pyximport; pyximport.install()

, but for me this is causing a compilation error with sklearn -> is there a way to make sure it uses the same options as the Makefile that runs successfully?

All in all, I'm looking for a guide on modifying a large cython project without spending decades waiting to recompile unmodified files.

+3


source to share


1 answer


You can just run,

python setup.py develop

      

after each modification. Unlike the command, install

this does not copy files and creates a symbolic link to the working directory. It will also automatically build all required extensions in equivalent



python setup.py build_ext --inplace

      

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

.

The module pyximport

is good for standalone Cython functions. However, for a more complex project with multiple files, the above approach is likely to be simpler.

+3


source







All Articles