0

I have some trouble to document my Cython (python 2.7) module with Sphinx (1.7).

I set the Cython directive embedsignature to True, and I also mock numpy in my conf.py file. However, if I run sphinx-build -b html source build I get the following TypeError:

WARNING: autodoc: failed to import module u'isolver'; the following exception was raised:
Traceback (most recent call last):
  File "C:\Users\xxx\Anaconda2\lib\site-packages\sphinx\ext\autodoc\importer.py", line 140, in import_module
    __import__(modname)
  File "c:\users\xxx\dropbox\github\isolver\isolver\__init__.py", line 1, in <module>
    import core
  File "c:\users\xxx\dropbox\github\isolver\isolver\core\__init__.py", line 1, in <module>
    import c_trf
  File "__init__.pxd", line 155, in init isolver.core.c_trf
TypeError: numpy.dtype is not a type object

The weird thing is I do not have a *.pxd file and line 155 in c_trf.pyx file is empty.

Perhaps the secret of this error lies in the way how I declared the numpy data types?

cimport numpy as np
import numpy as np

DTYPE_int = np.int64
ctypedef np.int64_t DTYPE_int_t

DTYPE_float = np.float64
ctypedef np.float64_t DTYPE_float_t

Or maybe the declarations of some functions with cdef np.ndarray fun(x):... are wrong?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Petermailpan
  • 103
  • 1
  • 10
  • https://stackoverflow.com/questions/10057476/how-do-i-use-sphinx-with-cython is relevant, but it looks like roughly what you're trying to do – DavidW Feb 23 '18 at 07:13
  • @DavidW: Thank you very much for your suggestion. I knew the post. So far I can tell about my problem: It looks like a "mock import" might not be enough here. But I am out of ideas how to fix this. – Petermailpan Feb 23 '18 at 11:46

0 Answers0