Is Blender extending python or embedding it?
If I understood correctly, the embedding means that python will be included in the source code for blender and is “expanded” while compiling. Whereas extending python with Blender means you can write a python script, write “from Blender import all” and voila, you run a Blender app.
If it is the first, which I think it is, where would you find the embedded code for python? Is it all in the “svn\blender\source\blender\python” sub-folder? and how is it than actually embedded into the Blender Kernel?
I have been reading the docs @ python, but it is still quite obscure matter for me
Extending and Embedding the Python Interpreter
I think it does both. An embedded python system is compiled into blender, but the python api that is available is an python extension. The source code is heavily mixed up with python C api calls. You can do a grep -r python.h and you will find a lot of files that include the python c library.
The most C++ classes in the blender gameengine are basically inheriting python code, with reference counting and stuff like that. Methods are wrapped into python to create the bge python api.
embedding basically means, that you can run python code in an c/c++ programm
extending means, that you have c/c++ code bundled as a .dll/.so that you can import dynamically at runtime into an python env.
One of my very first python hacks
Python is embedded in blender (runs scripts as part of the program, UI, operators, &etc) and can also be built as a python module so you can use it in any ol’ python 3.x interpreter.
Most of bpy is generated at compile time from makesrna so there isn’t a whole lot of raw python C api code in the source tree – though there is still quite a bit in there.
For most people - it embeds, you can for example - compile blender without python support. this however isnt as useful as it was in 2.4x because most of the UI is missing now.
Compiling as a python module is possible as Uncle Entity states - though this is really only for people who like to mess with python and not apart of our official releases, also note that it doesn’t give any UI access - it runs blender headless.
Also minor correction, bpy thin wraps generated code, its not generated its self.
and how would you do that? This is what you mean with Headless, Right?
Both are advanced cmake options (you need to toggle advanced)
WITH_PYTHON - without python you dont get much UI, its not really usable, though it can render.
WITH_HEADLESS - means blender cant open any windows, it can render and run non interactive python scripts, could use on a server.