How should I structure a Python package that contains Cython code

StackOverflow

I"d like to make a Python package containing some Cython code. I"ve got the the Cython code working nicely. However, now I want to know how best to package it.

For most people who just want to install the package, I"d like to include the .c file that Cython creates, and arrange for setup.py to compile that to produce the module. Then the user doesn"t need Cython installed in order to install the package.

But for people who may want to modify the package, I"d also like to provide the Cython .pyx files, and somehow also allow for setup.py to build them using Cython (so those users would need Cython installed).

How should I structure the files in the package to cater for both these scenarios?

The Cython documentation gives a little guidance. But it doesn"t say how to make a single setup.py that handles both the with/without Cython cases.





Tutorials