Cython C-level Interface Of Package: *.pxd Files Are Not Found
Solution 1:
Cython does not support implicit namespace packages as of yet. That is, cython searches only subdirectories that contain a file init.*
, whereby *
can be anything from py
, pyc
, pyx
, and pxd
.
I have created a bugtracker report for this issue, in case you want to follow up on whether the issue has been fixed in a newer version yet (I worked with Cython 0.29.14).
Until then, a workaround is to create an empty file __init__.pxd
in the folder nsp
. This file should be ignored by python, as it is not a *.py
file, and lets cython search the subdirectories for packages. The file structure then reads as follows:
├── nsp
│ ├── __init__.pxd
│ └── A
| ├── extension.pxd
| ├── extension.pyx
│ └── __init__.py
└── setup.py
To install the additional file __init__.pxd
in the namespace package, change the packages
argument of setup(...)
to packages=['nsp', 'nsp.A']
and the package_data
argument to package_data={'': ['*.pxd', '*.pyx']}
.
Edit:
The bug has been known to the cython developers and will be fixed in version 3. See Fix for cimport from PEP420 namespace.
Post a Comment for "Cython C-level Interface Of Package: *.pxd Files Are Not Found"