0

I have a file that I want to "cythonize", myfile.pyx. I also have a helper file, myhelper.pxi.

myfile.pyx contains within it the following line:

include 'myhelper.pxi'

If the helper file was not needed, I think setup.py would look like this:

from distutils.core import setup
from Cython.Build import cythonize
import numpy

setup(
    ext_modules = cythonize("myfile.pyx")
)

Can you tell me how to properly incorporate the helper file into the setup.py code?

Andy
  • 131
  • 8

1 Answers1

0

It's fine as is - setup.py only needs to know about "myfile.pyx". It doesn't need to know about the internal details of "myfile.pyx" (i.e. what files it textually includes).

This does mean that setup.py won't recompile things when you've only changed "myhelper.pxi" because it doesn't know about the dependency. There isn't really a good way round that. Use --force on the command line to make setup rebuild everything if that's a problem.

ngoldbaum
  • 5,430
  • 3
  • 28
  • 35
DavidW
  • 29,336
  • 6
  • 55
  • 86
  • Thanks David, that does seem to help. I am getting a different issue now, but I'll create a separate question for this: fatal error C1083: Cannot open include file: 'numpy/arrayobject.h': No such file or directory – Andy Jan 05 '20 at 19:41
  • That's absolutely nothing to do with you using a pxi file. If you search for that error message you'll find plenty of suggestions that tell you what to add to setup.py to get the correct include path – DavidW Jan 05 '20 at 19:43
  • https://stackoverflow.com/questions/2379898/make-distutils-look-for-numpy-header-files-in-the-correct-place/2379912#2379912 – DavidW Jan 05 '20 at 19:51