From 1bfdacb00fcf56b71c112840ee1a66a777cb20b7 Mon Sep 17 00:00:00 2001 From: "alexey.stratulat" <alexey.stratulat@demlabs.net> Date: Fri, 21 Feb 2020 19:12:40 +0700 Subject: [PATCH] Fix. Import of the dynamic library has worked, though so far only though 'import CellFrame.libCellFrame' --- include/python-cellframe.h | 4 ++-- setup.py | 7 +++++-- src/__init__.py | 2 +- src/python-cellframe.c | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/python-cellframe.h b/include/python-cellframe.h index d7d9ce85..d5439a7e 100644 --- a/include/python-cellframe.h +++ b/include/python-cellframe.h @@ -114,14 +114,14 @@ static PyMethodDef CellFramePythonMethods[] = { static struct PyModuleDef CellFramePythonModule = { PyModuleDef_HEAD_INIT, - "CellFrame", /* name of module */ + "libCellFrame", /* 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. */ CellFramePythonMethods }; -PyMODINIT_FUNC PyInit_CellFrame(void); +PyMODINIT_FUNC PyInit_libCellFrame(void); #ifdef __cplusplus } diff --git a/setup.py b/setup.py index d7673bae..26f5de90 100644 --- a/setup.py +++ b/setup.py @@ -73,9 +73,12 @@ setup( author='DEMLABS Inc. (2017-2020)', license="GNU GPLv3", packages=['CellFrame'], - ext_modules=[CMakeExtension('CellFrame')], + ext_modules=[CMakeExtension('CellFrame/libCellFrame')], # add custom build_ext command - cmdclass=dict(build_ext=CMakeBuild), + cmdclass={ + 'build_ext': CMakeBuild + }, +# cmdclass=dict(build_ext=CMakeBuild), zip_safe=False, # tests_require=['pytest'], # setup_requires=setup_requires diff --git a/src/__init__.py b/src/__init__.py index 4e6e61f6..a6c59c1e 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +1 @@ -from .CellFrame import * +#from .libCellFrame import * diff --git a/src/python-cellframe.c b/src/python-cellframe.c index 608631e1..12f43303 100644 --- a/src/python-cellframe.c +++ b/src/python-cellframe.c @@ -291,7 +291,7 @@ static PyObject *python_cellframe_init(PyObject *self, PyObject *args){ return PyLong_FromLong(0); } -PyMODINIT_FUNC PyInit_CellFrame(void){ +PyMODINIT_FUNC PyInit_libCellFrame(void){ if (PyType_Ready(&DapObject_DapObjectType) < 0 || PyType_Ready(&dapCrypto_dapCryptoType) < 0 || PyType_Ready(&ServerCore_ServerCoreType) < 0 || PyType_Ready(&dapEvents_dapEventsType) < 0 || @@ -459,7 +459,7 @@ int main(int argc, char **argv) { } /* Add a built-in module, before Py_Initialize */ - PyImport_AppendInittab("CellFrame", PyInit_CellFrame); + PyImport_AppendInittab("libCellFrame", PyInit_libCellFrame); /* Pass argv[0] to the Python interpreter */ Py_SetProgramName(program); @@ -470,7 +470,7 @@ int main(int argc, char **argv) { /* Optionally import the module; alternatively, import can be deferred until the embedded script imports it. */ - PyImport_ImportModule("CellFrame"); + PyImport_ImportModule("libCellFrame"); PyMem_RawFree(program); return 0; -- GitLab