I'm new to Cython, so I might be missing something obvious, but I've read through the documentation and been banging my head against this for a while.
I have a *.pyx
file that I build using a setup.py
file as follows:
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("path/to/helpers.pyx"),
)
That works fine, and I can now import path.to.helpers
from sister directories and subdirectories without any issues.
Now, recently I decided I want to add a helpers.pxd
file as well, so I can cimport
parts of it to other Cython modules. I've added a helpers.pxd
in path/to
to facilitate this, but when I try to cimport path.to.helpers
, I get
path/to/helpers.pxd not found
errors. Do I need to change something in my setup.py
file to allow cimport
ing from the *.pxd
file?
None of the docs I've found say anything about doing this, and I feel like I've tried everything without any luck. Ideas?
Finally fixed this after hours of banging my head against it.
*.pxd
files are much more finicky aboutpath
than*.pyx
files, it turns out. I have no idea why. Anyway, just adding the path to my*.pxd
file fixed the problem. Mysetup.py
forpath/to/helpers.*
stays the same, but whenever I'm using any other*.pyx
files that need access topath.to.helpers
, I make sure the path topath/to/helpers
is included as aninclude-dir
, like:cython *.pyx *.pxd -a --cplus --include-dir ../some/path