Skip to content

Instantly share code, notes, and snippets.

@embray
Last active April 11, 2016 11:19
Show Gist options
  • Save embray/12a67edb82b213217e31f408007898e6 to your computer and use it in GitHub Desktop.
Save embray/12a67edb82b213217e31f408007898e6 to your computer and use it in GitHub Desktop.
Example Cython project with sharing between pyx file and plain C file
cdef public void hello():
print "Hello world!"
#include <stdio.h>
#include <Python.h> /* Required for foo.h to work--should probably be included directly in foo.h */
#include "foo.h"
void greeting(void) {
hello();
}
from setuptools import setup, Extension
from Cython.Build import cythonize
ext = cythonize(Extension('foo', sources=['foo.pyx', 'fooutil.c']))
setup(
name='foo',
version='0.1',
py_modules=['foo'],
ext_modules=ext
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment