How to build a Python C Extension so I can import it from a module
I have a Python project with many sub-modules that I package up with distutils. I would like to build some Python extensions in C to live in some of these sub-modules but I don't understand how to get the Python extension to live in a submodule. What follows is the simplest example of what I'm looking for: Here is my Python extension c_extension.c : #include <Python.h> static PyObject * get_answer(PyObject *self, PyObject *args) { return Py_BuildValue("i", 42); } static PyMethodDef Methods[] = { {"get_answer", get_answer, METH_VARARGS, "The meaning of life."}, {NULL, NULL, 0, NULL} };