commit 89e225a4d928a7c99bc5730b4c87a6c9b68e189d Author: Volker Birk Date: Tue Aug 2 15:56:14 2016 +0200 initial commit diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..ca5c2cc --- /dev/null +++ b/.hgignore @@ -0,0 +1,5 @@ +syntax: glob + +*.swp +*.o +*.so diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ddb6834 --- /dev/null +++ b/setup.py @@ -0,0 +1,15 @@ +from distutils.core import setup, Extension + +module_pEp = Extension('pEp', + sources = ['src/pEpmodule.cc',], + include_dirs = ['/Users/vb/include',], + library_dirs = ['/Users/vb/lib',], + libraries = ['pEpEngine',], + ) + +setup( + name='pEp Python adapter', + version='1.0', + description='Provides a Python module giving access to pEp engine', + ext_modules=[module_pEp] + ) diff --git a/src/pEpmodule.cc b/src/pEpmodule.cc new file mode 100644 index 0000000..bf83660 --- /dev/null +++ b/src/pEpmodule.cc @@ -0,0 +1,21 @@ +#include "pEpmodule.hh" +#include + +namespace pEp { + namespace PythonAdapter { + PyObject *about(PyObject *self, PyObject *args) + { + return PyUnicode_FromString(version_string); + } + } +} + +PyMODINIT_FUNC PyInit_pEp(void) +{ + PEP_SESSION session; + PEP_STATUS status = init(&session); + if (status != PEP_STATUS_OK) + return NULL; + + return PyModule_Create(&pEpmodule); +} diff --git a/src/pEpmodule.hh b/src/pEpmodule.hh new file mode 100644 index 0000000..d5cdda6 --- /dev/null +++ b/src/pEpmodule.hh @@ -0,0 +1,25 @@ +#include + +namespace pEp { + namespace PythonAdapter { + const char *version_string = "p≡p Python adapter version 0.1"; + + PyObject *about(PyObject *self, PyObject *args); + } +} + +static PyMethodDef pEpMethods[] = { + {"about", pEp::PythonAdapter::about, METH_VARARGS, "about p≡p"}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef pEpmodule = { + PyModuleDef_HEAD_INIT, + "pEp", + NULL, + -1, + pEpMethods +}; + +PyMODINIT_FUNC PyInit_pEp(void); +