Ilan Schnell, 2008-07-13
SVN: https://svn.enthought.com/svn/sandbox/embedder/
This tool generates C code suitable for the simplest form of embedding
a Python script in C (very high level embedding).
The generated C code, which is basically a call to PyRun_SimpleString,
features different levels of obfuscation for the string passed to this
C/API function, such that inspecting a compiled binary which includes
the generated code does not include the Python source as a plain string.
Examples and use cases:
insert_into_python.sh -- how to insert a snippet of Python code
into the main Python interpreter itself
standalone/ -- how to create a standalone C file (which will of
course still link to libpython) which executes
Python code.
extend/ -- how to create an extension module which executes some
Python code (from C) when imported.
There are many other situations in which one might want to call Python from C. However, most of them will go below very high level embedding, i.e. calling a Python function from C (with arguments and return value). These cases are more complicated and there are almost no tools for automating such tasks; these tool would be the opposite of wrapper tools like SWIG.
References: