Document how to embed Cython modules in C/C++ applications
See original GitHub issueThe documentation on embedding is inherently lacking. Even the one in the CPython docs is incomplete at best.
There are some hints in the Wiki, there’s the --embed
option to the cython
and cythonize
frontends, the embedding demo, the PyImport_AppendInittab()
function in CPython and the documentation of the module init function in CPython.
All of these are incomplete and none of them gives the whole picture in one place. There should be a dedicated documentation page in the Cython docs for this, and the documentation in the CPython docs is also worth improving.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Embedding Cython modules in C/C++ applications
See the documentation of the module init function in CPython and PEP 489 ... the main steps for embedding a Cython module (...
Read more >Add python modules to cython for use in c - Stack Overflow
When you read the documentation, you'd have seen that all the examples ("Using Cython declarations from C" and "Embedding Cython modules.
Read more >[cython-users] embedding many cython modules in C++ project
So currently I've got a makefile that identifies all pyx/py files and runs cython on them to generate .cpp files. The compiler is...
Read more >Extending and Embedding the Python Interpreter — Python ...
This document describes how to write modules in C or C++ to extend the Python interpreter with new modules. Those modules can not...
Read more >Write C++ extensions for Python - Visual Studio (Windows)
To create a C++ file in the new project, right-click the Source Files node, and then select Add > New Item. Select C++...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please don’t use the bug tracker for general discussions. We have the cython-users mailing list for this.
FWIW I have a working example of how to call
PyInit_*
on a multi-phase init module therefore avoiding the need to usePyImport_AppendInittab
. Essentially it’s running through the multi-phase init steps manually. I’m not sure if we want to put it in any updated embedding docs, but it’s posted below in case anyone wants to document it properly:I suspect this comes under
though
I remain sceptical of whether embedding Cython in C/C++ applications is actually useful (because people expect it to embed their module and all its dependencies), but multi-phase init is definitely something that people fight with, and additional ways to work with it are probably good.