如何在“;Python/capi”;?
您好,我正在开发一个python模块,我有以下问题。编译模块时,只有一个函数可用(fun1)。如何使fun2也可用? 代码:如何在“;Python/capi”;?,python,c,python-module,Python,C,Python Module,您好,我正在开发一个python模块,我有以下问题。编译模块时,只有一个函数可用(fun1)。如何使fun2也可用? 代码: #define PY_SSIZE_T_CLEAN #include <Python.h> static PyObject* spam_fun2(PyObject *self) { # codigos return Py_None; } static PyObject* spam_fun1(PyObject *self) { #
#define PY_SSIZE_T_CLEAN
#include <Python.h>
static PyObject* spam_fun2(PyObject *self)
{
# codigos
return Py_None;
}
static PyObject* spam_fun1(PyObject *self)
{
# codigos
return Py_None;
}
static struct PyModuleDef spammethods[] = {
{ "fun1", spam_fun1, METH_NOARGS, " " },
{ "fun2", spam_fun2, METH_NOARGS, " " },
{ NULL, NULL, 0, NULL }
};
static struct PyModuleDef spammodule = {
PyModuleDef_HEAD_INIT,
"spam",
"Lib exe command",
-1,
spammethods
};
PyMODINIT_FUNC PyInit_spam()
{
return PyModule_Create(&spammodule);
}
from distutils.core import setup
from distutils.core import Extension
setup(
name='spam',
version='1.0',
ext_modules=[Extension('spam', ['spam.c'])]
)