When calling cython on the command line, it's possible to tell it to create a int main() method that embeds the Python interpreter:
$ cython --embed main.pyx
$ grep 'int main' main.c
int main(int argc, char** argv) {
However, when you import Cython directly, e.g. from a distutils setup.py script, the embed option seems to be ignored:
$ python3
>>> from Cython.Compiler import Options
>>> Options.embed = True
>>> from Cython.Build import cythonize
>>> cythonize('main.pyx')
[1/1] Cythonizing main.pyx
>>>
$ grep 'int main' main.c
$
What is it that I'm doing wrong here?
I figured it out from Cython's sources.
It looks like Cython expects a specific value for Options.embed:
Options.embed = "main"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With