I have been looking at the Python/C API for embedding my python script into C. I want to know if there is an easy (or simpler) way to embed my python script without having to get too involved in the python/c API. I should mention (cause I am not sure if this will be a problem) that in my python script I am using a number of other modules in my python script (NumPy, SciPy, Matplotlib and Mayavi to be exact). Any help or advice you might be able to give would be greatly appreciated.
Asked
Active
Viewed 201 times
1
-
2Actually, embedding Python is surprisingly easy: http://docs.python.org/2/extending/embedding.html#very-high-level-embedding – NPE Dec 17 '12 at 20:32
-
I thought Cython was for writing C extensions for Python, which if I am not mistaken is the opposite of embedding. Please correct me if I am wrong. – user1750948 Dec 17 '12 at 20:42
-
@user1750948: Quoting from the About page: "This makes Cython the ideal language for wrapping external C libraries, **embedding CPython into existing applications**, and for fast C modules that speed up the execution of Python code." – abarnert Dec 17 '12 at 20:56
-
1`cython` because ultimately it is also generating `c` equivalent code.. .without too much focus on `c` and just doing everything in pythonic way! – namit Dec 17 '12 at 21:10
-
Yes you guys are correct. It appears that Cython can be used for embedding according to this page: http://docs.cython.org/src/userguide/external_C_code.html. – user1750948 Dec 17 '12 at 21:40
-
I know this a an old thread, but I figured I would give this a shot. I was wondering if it is possible to create a DLL from the cython code – user1750948 Jul 18 '13 at 13:32