Files
CMake/Tests/FindPython/TEST_spam.c
Marc Chevrier 9b0510fa57 FindPython: add support for multiple searches in same directory
In some situations, like cross-compilation, it can be required to search for
the host python interpreter as well as the cross-compilation development
artifacts.
By managing different prefixes for the artifacts, multiple and independent
searches can be achieved.
2025-01-11 15:47:06 +01:00

42 lines
1005 B
C

#define Py_LIMITED_API 3
#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 PyLong_FromLong(sts); */
return Py_BuildValue("i", sts);
}
static PyMethodDef SpamMethods[] = {
{ "system", spam_system, METH_VARARGS, "Execute a shell command." },
{ NULL, NULL, 0, NULL } /* Sentinel */
};
#if defined(PYTHON2)
PyMODINIT_FUNC initTEST_spam2(void)
{
(void)Py_InitModule("TEST_spam2", SpamMethods);
}
#endif
#if defined(PYTHON3)
static struct PyModuleDef spammodule = {
PyModuleDef_HEAD_INIT, "TEST_spam3", /* name of module */
NULL, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
SpamMethods
};
PyMODINIT_FUNC PyInit_TEST_spam3(void)
{
return PyModule_Create(&spammodule);
}
#endif