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

Add CYTHON_NO_EXPORTS macro. #1944

Closed
AraHaan opened this issue Oct 19, 2017 · 2 comments
Closed

Add CYTHON_NO_EXPORTS macro. #1944

AraHaan opened this issue Oct 19, 2017 · 2 comments
Labels
Milestone

Comments

@AraHaan
Copy link
Contributor

AraHaan commented Oct 19, 2017

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.

@scoder
Copy link
Contributor

scoder commented Oct 20, 2017

I'm generally ok with adding something like this, but I would make the name more specific, like CYTHON_NO_PYINIT_EXPORT. And I would also like to avoid redefining PyMODINIT_FUNC and instead use a separate internal macro __Pyx_PyMODINIT_FUNC.

Please provide a pull request, including test and documentation. See the embedding test for that, under Demos/embed. Probably also something to consider in cython_freeze.

And since you asked: no, this is nothing to add in a bug-fix point release.

AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
@AraHaan
Copy link
Contributor Author

AraHaan commented Oct 21, 2017

Alright so, I just need the test and a change of documentations in places.

AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
AraHaan added a commit to AraHaan/cython that referenced this issue Oct 21, 2017
When building the generated code in an embedded interpreter the module
init function will no longer be exported if CYTHON_NO_PYINIT_EXPORT is defined.

See cython#1944 for details.
scoder added a commit that referenced this issue Oct 28, 2017
Add CYTHON_NO_PYINIT_EXPORT macro. (#1944)
@scoder scoder added this to the 0.28 milestone Oct 31, 2017
@scoder scoder closed this as completed Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants