Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use Sphinx with Cython?
    primarykey
    data
    text
    <p>I have recently Cythonized a project of mine by renaming all of the modules (except for the top-level <code>__init__.py</code>) to <code>*.pyx</code>, and by putting <code>ext_modules = [Extension('foo', ['foo.pyx'])]</code> in <code>setup.py</code>. Building and installing works fine. However, when I do <code>cd doc; make html</code>, Sphinx fails because it cannot import any of the modules which are now <code>*.pyx</code>.</p> <p>If I edit <code>doc/conf.py</code> and change <code>sys.path.insert(0, os.path.abspath('..'))</code> to <code>sys.path.insert(0, os.path.abspath('../build/temp.linux-x86_64-2.7'))</code>, then Sphinx can find all of the modules and can generate documentation, but in that case I get errors like <code>error while formatting arguments for foo.bar: &lt;built-in function bar&gt; is not a Python function</code>. Presumably this is because now Sphinx only has access to the <code>*.so</code> files, not the source files. That same <code>sys.path</code> modification also allows running the doctests via Sphinx (<code>make doctest</code>).</p> <p>The other solution I tried was using the extension <code>*.py</code> instead of <code>*.pyx</code> (and using <code>ext_modules = [Extension('foo', ['foo.py'])]</code> in <code>setup.py</code>). In this case, the documentation builds correctly, but I think the doctests now bypass Cython.</p> <p>I have not been able to find any information online regarding using Sphinx and Cython together. I have looked at source code for some projects which use both, but they don't seem to make use of docstrings in the <code>*.pyx</code> files. I know that Sage does, but that project is too complicated for me to pick apart.</p> <p>Does Sphinx support docstrings in Cython files? If so, how do I make this work?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload