title: Cython cimport cannot find .pxd module
body: <p><em>Solved, see Edit #3</em></p>
  
  <p>Assume a package is structured as:</p>
  
  <pre><code>Some_Package/ 
      some_package/
          __init__.py
          core/
              __init__.py
              definition.pxd
          helper/
              __init__.py
              helper.pxd
              helper.pyx
      setup.py
  </code></pre>
  
  <p>Where in <code>definition.pxd</code> I have:</p>
  
  <pre><code>import numpy as np
  cimport numpy as np
  # ...
  ctypedef np.int32_t INT_t
  </code></pre>
  
  <p>And in <code>helper.pxd</code> I have:</p>
  
  <pre><code>cimport some_package.core.definition
  from some_package.core.definition cimport INT_t
  # ...
  </code></pre>
  
  <p>In <code>helper.pyx</code> I didn't <code>cimport</code> anything. I configured <code>setup.py</code> as:</p>
  
  <pre><code>ext_modules=cythonize('./some_package/helper/helper.pyx', include_dirs=['.', './some_package/core'])
  </code></pre>
  
  <p>Now my problem is with <code>python setup.py build_ext --inplace</code> I can build successfully into <code>.so</code>, but when I tried to <code>import some_package.helper.helper</code> I got an <code>ImportError</code>:</p>
  
  <p><code>ImportError: No module named "some_package.helper.helper"</code></p>
  
  <p>I have looked into <code>helper.cpp</code> and found some lines like:</p>
  
  <pre><code>  __pyx_t_1 = __Pyx_ImportModule("some_package.core.definition"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  </code></pre>
  
  <p>I guess this might have something to do with import path, but I cannot spot what was wrong. All <code>__init__.py</code>'s are empty and I have imported <code>absolute_import</code> in every file. I also changed the <code>include_dirs</code>, but still not working.</p>
  
  <p><strong>Edit #1</strong></p>
  
  <p>According to the <a href="http://cython.readthedocs.io/en/latest/src/userguide/sharing_declarations.html#search-paths-for-definition-files" rel="nofollow noreferrer">documentation</a>, <code>include_dirs</code> adds to the <code>*.pxd</code> search path. So I also tried to change the <code>cimport</code> statements in <code>helper.pxd</code> as:</p>
  
  <pre><code>cimport definition
  from definition cimport INT_t
  </code></pre>
  
  <p>This time, <code>cython</code> cannot compile: <code>"definition.pxd" not found</code>. However, it should be in the search path.</p>
  
  <p><strong>Edit #2</strong></p>
  
  <p>A quick workout is adding an empty <code>definition.pyx</code> in <code>core/</code>, then configure extensions as:</p>
  
  <pre><code>extensions = [
      Extension("some_package.core.definition", ["some_package/core/definition.pyx"])
      Extension("some_package.helper.helper", ["some_package/helper/helper.pyx"])
  ]
  </code></pre>
  
  <p>Then in <code>setup.py</code>:</p>
  
  <pre><code>ext_modules=cythonize(extensions)
  </code></pre>
  
  <p>Now <code>cimport some_package.core.definition</code> is working in <code>helper.pxd</code>.</p>
  
  <p>However, this is not elegant.</p>
  
  <p><strong>Edit 3</strong></p>
  
  <p>I finally found I have overlook some lines like:</p>
  
  <pre><code>cdef INT_t some_int = 1
  </code></pre>
  
  <p>However, in the <code>.pxd</code> file, there cannot be any <em>executable</em> code. In this case, it seems <code>Cython</code> treats it as a package, which is not as there is <code>.pyx</code> file.</p>
  
  <p>There might be two methods to work around:</p>
  
  <ol>
  <li><p><code>cdef extern</code> from a <code>C</code> header.</p></li>
  <li><p>Wrap-up to inline functions.</p></li>
  </ol>