tests/fixtures/projects/demo-cextension/my_package/hellomodule.c
raw| 1 | #include <Python.h> |
| 2 | |
| 3 | static PyObject* helloworld(PyObject* self, PyObject* args) |
| 4 | { |
| 5 | printf("Hello World\n"); |
| 6 | return Py_None; |
| 7 | } |
| 8 | |
| 9 | static PyMethodDef myMethods[] = { |
| 10 | { "helloworld", helloworld, METH_NOARGS, "Prints Hello World" }, |
| 11 | { NULL, NULL, 0, NULL } |
| 12 | }; |
| 13 | |
| 14 | static struct PyModuleDef hellomodule = { |
| 15 | PyModuleDef_HEAD_INIT, |
| 16 | "hello", |
| 17 | "Test Module", |
| 18 | -1, |
| 19 | myMethods |
| 20 | }; |
| 21 | |
| 22 | PyMODINIT_FUNC PyInit_hello(void) |
| 23 | { |
| 24 | return PyModule_Create(&hellomodule); |
| 25 | } |