title: Packaging interdependent Cython extensions
body: <p>I have written 3 Cython extensions, and I would like to package them in a tidy way that I can distribute to coworkers to use in Python, without them needing a C compiler installed.</p>
  <p>Directory structure is:</p>
  <pre><code>myproject\
  |---- setup.py
  |---- gamma-source\
  |      |---- eta.pxd
  |      |---- eta.pyx
  |      |---- omega.pxd
  |      |---- omega.pyx
  |      |---- rho.pxd
  |      |---- rho.pyx
  </code></pre>
  <p>Where <code>omega</code> has a cimport from <code>rho</code>, <code>eta</code> has a cimport and an import from <code>omega</code>, <code>rho</code> has cimports from <code>eta</code> and <code>omega</code>.</p>
  <p>My <code>setup.py</code> is:</p>
  <pre><code>from setuptools import setup, Extension
  from Cython.Build import cythonize
  
  __version__ = '0.1.0'
  
  exts = [Extension(&quot;eta&quot;,
                    sources = [&quot;gamma-source\\eta.pyx&quot;]),
          Extension(&quot;omega&quot;,
                    sources = [&quot;gamma-source\\omega.pyx&quot;]),
          Extension(&quot;rho&quot;,
                    sources = [&quot;gamma-source\\rho.pyx&quot;]),
         ]
  
  setup(name=&quot;gamma&quot;,
        version=__version__,
        ext_modules = cythonize(exts,
                                compiler_directives = {'language_level':'3'}
                                ),
        zip_safe = False,
        )
  </code></pre>
  <p>and using <code>python setup.py install</code> gets me working on my own machine, but:</p>
  <ol>
  <li>The <code>.pyd</code> files are dropped into my <code>site-packages</code> folder rather than being in <code>site-packages\rho</code>, which is untidy.</li>
  <li>This method requires me to <code>import eta, omega, rho</code> instead of <code>from gamma import omega</code> or <code>import gamma.omega</code>, which I would prefer if possible.</li>
  </ol>
  <p>I tried changing setup.py to:</p>
  <pre><code>exts = [Extension(&quot;gamma.eta&quot;,
                    sources = [&quot;gamma-source\\eta.pyx&quot;]),
          Extension(&quot;gamma.omega&quot;,
                    sources = [&quot;gamma-source\\omega.pyx&quot;]),
          Extension(&quot;gamma.rho&quot;,
                    sources = [&quot;gamma-source\\rho.pyx&quot;]),
         ]
  </code></pre>
  <p>but <code>python setup.py develop</code> gives me:</p>
  <pre><code>error: could not create 'gamma\rho.cp39-win_amd64.pyd': No such file or directory.
  </code></pre>
  <p>I then tried putting a <code>gamma</code> directory into <code>myproject</code>, and then it would install, but I found that
  <code>from gamma import omega</code> worked but importing either <code>eta</code> and <code>rho</code> gave me</p>
  <pre><code>ModuleNotFoundError: No module named 'rho'
  </code></pre>
  <p>I then tried changing the imports from <code>from omega cimport omega_class</code> to <code>from .omega cimport omega_class</code> in the hope that that would get the modules to find each other, but that wouldn't compile - <code>eta.pyx</code> couldn't find <code>omega_class</code>.</p>
  <p>I tried adding a blank <code>__init__.py</code> file to <code>gamma-source</code>, but that also wouldn't compile.</p>
  <p>Where am I going wrong? How should I package these extensions into a coherent unit? I'm happy to share more detailed error info from any of the approaches I took, but not sure which of them would be fruitful.</p>
  <p>This question looked like it might be hitting the same issue, but it wasn't clear to me how I would apply the given solution:
  <a href="https://stackoverflow.com/questions/56560007/building-python-package-containing-multiple-cython-extensions">Building Python package containing multiple Cython extensions</a></p>