initial
This commit is contained in:
commit
760f6b9f3b
8
setup.py
Normal file
8
setup.py
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
|
||||
module1 = Extension('spam', sources = ['spammodule.c'])
|
||||
|
||||
setup(name = 'pkgname', version = '1.0',
|
||||
description = 'this is the package description',
|
||||
ext_modules = [module1])
|
29
spammodule.c
Normal file
29
spammodule.c
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
static PyObject *
|
||||
spam_system(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *command;
|
||||
int sts;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &command))
|
||||
return NULL;
|
||||
sts = system(command);
|
||||
return Py_BuildValue("i", sts);
|
||||
}
|
||||
|
||||
static PyMethodDef SpamMethods[] = {
|
||||
{"system", spam_system, METH_VARARGS, "Execute a shell command."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
initspam(void)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
m = Py_InitModule("spam", SpamMethods);
|
||||
if (m == NULL)
|
||||
return;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user