Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of missing file required for PyKX Compilation #9

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pykx/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Auto-generated files
*.c
!_pykx_helpers.c
!_numpy.c
!python.c
!pykx.c
Expand Down
35 changes: 35 additions & 0 deletions src/pykx/_pykx_helpers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#define PY_SSIZE_T_CLEAN
#include <assert.h>
#include <stddef.h>
#include <string.h>
#include <Python.h>


static PyObject* clear_all_errors(PyObject* self, PyObject* args) {
PyErr_Clear();
Py_RETURN_NONE;
}


static PyMethodDef _HelperMethods[] = {
{"clean_errors", clear_all_errors, METH_NOARGS, "Clean the python error state."},
{NULL, NULL, 0, NULL} // Sentinel
};


static struct PyModuleDef _helpermodule = {
PyModuleDef_HEAD_INIT,
"_pykx_helpers",// Module name.
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.
_HelperMethods, // Module methods.
NULL, // Module slots.
NULL, // A traversal function to call during GC traversal of the module object.
NULL, // A clear function to call during GC clearing of the module object.
NULL // A function to call during deallocation of the module object.
};


PyMODINIT_FUNC PyInit__pykx_helpers(void) {
return PyModule_Create(&_helpermodule);
}