Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've done this myself now, in a Python package <a href="http://pypi.python.org/pypi/simplerandom" rel="noreferrer"><code>simplerandom</code></a> (<a href="http://bitbucket.org/cmcqueen1975/simplerandom" rel="noreferrer">BitBucket repo</a> - EDIT: now <a href="https://github.com/cmcqueen/simplerandom" rel="noreferrer">github</a>) (I don't expect this to be a popular package, but it was a good chance to learn Cython).</p> <p>This method relies on the fact that building a <code>.pyx</code> file with <code>Cython.Distutils.build_ext</code> (at least with Cython version 0.14) always seems to create a <code>.c</code> file in the same directory as the source <code>.pyx</code> file.</p> <p>Here is a cut-down version of <code>setup.py</code> which I hope shows the essentials:</p> <pre><code>from distutils.core import setup from distutils.extension import Extension try: from Cython.Distutils import build_ext except ImportError: use_cython = False else: use_cython = True cmdclass = { } ext_modules = [ ] if use_cython: ext_modules += [ Extension("mypackage.mycythonmodule", [ "cython/mycythonmodule.pyx" ]), ] cmdclass.update({ 'build_ext': build_ext }) else: ext_modules += [ Extension("mypackage.mycythonmodule", [ "cython/mycythonmodule.c" ]), ] setup( name='mypackage', ... cmdclass = cmdclass, ext_modules=ext_modules, ... ) </code></pre> <p>I also edited <code>MANIFEST.in</code> to ensure that <code>mycythonmodule.c</code> is included in a source distribution (a source distribution that is created with <code>python setup.py sdist</code>):</p> <pre><code>... recursive-include cython * ... </code></pre> <p>I don't commit <code>mycythonmodule.c</code> to version control 'trunk' (or 'default' for Mercurial). When I make a release, I need to remember to do a <code>python setup.py build_ext</code> first, to ensure that <code>mycythonmodule.c</code> is present and up-to-date for the source code distribution. I also make a release branch, and commit the C file into the branch. That way I have a historical record of the C file that was distributed with that release.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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