Skip to content

Add CYTHON_NO_EXPORTS macro. #1944

@AraHaan

Description

@AraHaan

The reason for this macro is for when someone wants to PyImport_AppendInittab an cython C code generated module on their own embedded python interpreter. As such then it avoid's exporting symbols on exe files which is a bad idea.

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init[modulename](void); /*proto*/
PyMODINIT_FUNC init[modulename](void)
#else
+ #ifdef CYTHON_NO_EXPORTS
+ /* when compiling cython code in user made embedded python applications.*/
+ #undef PyMODINIT_FUNC
+ #define PyMODINIT_FUNC PyObject*
+ #endif
PyMODINIT_FUNC PyInit_[modulename](void); /*proto*/

And yes it's good to have this define constant in all cython generated modules to prevent the annoying exports. In this case of mine I must use cython on this module and I must not use cython for the embedding as I have to run some other things on it on top of the cython stuff that the cythonized module cant do.

When I added this it has no difference in runtime and it does not export the PyInit_ function on the module it uses as I am embedding python 3.6.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions