Compiling Cython on Build Packages

I am developing a Python package, EcoPy , which is mostly written in pure Python. The main folder is called ecopy. There is a subfolder in there called regression which has a Cython file already generated. The main setup.py file contains the code:

ext_modules = cythonize([
    Extension(
        'ecopy.regression.isoFunc', ['ecopy/regression/isoFunc.pyx'], **opts),
])

      

When I ran

sudo pip install ecopy -e . --upgrade --force-reinstall

      

the module builds fine. It even recompiles the isoFunc.c file if I delete it. The problem is that Cython doesn't convert the .c file to the .so file that I need to import the function. If I try to load the module without it, I get

ImportError: No module named isoFunc

      

If I manually configure the file using the command line

python setup.py build_ext --inplace

      

Cython DOES will generate a .so file. How do I get it to create a .so file using pip? I tried to figure out how the statsmodels do it by reading their code, but honestly this is a mystery to me.

It's almost as if pip is missing the build_ext argument.

+3


source to share


1 answer


I can answer this question because I just found out that I am an idiot.

sudo pip install ecopy -e . --upgrade --force-reinstall

      

was using an older version of PyPI that didn't have a new setup.py with Cython code. When i did it right



sudo pip install -e . --upgrade --force-reinstall

      

and used the latest version on my hard drive, it worked great.

Small victories.

+2


source







All Articles