From BlenderWiki

Jump to: navigation, search

UPDATE: this is now drafted at BlenderDev/PythonBlender

this is one take on PythonArchitecture

used to be at but was moved here.


The purpose of this document is to study the feasibility of making Blender a package of Python modules, or in a way, enabling using it to make Python applications. If successful, this could result in the official Blender itself becoming one. However, there are many obstacles and issues that require careful consideration, as will be discussed here.

Blender as Python module(s)

(how to discuss this separately from modularization, which is entangled in now?)

This would mean that all of Blender would be refactored as libraries, which would also be made Python modules. This way Blender could be a Python package (basically just a directory), that includes the parts i.e. (sub)libraries as modules. The ways of restructuring the core are also independent of this Python issue, but if such restructuring and packaging is done for other reasons, it would facilitate making the libraries Python modules too. For example, if the user interface would be a separate component that just used the core, the core would have to provide the means to make the UI. Then, that functionality could be exposed to Python , and it could be used to fully program the GUI (although as the actual UI library is implemented in C, it is not quite as simple as that).

Then making Blender to extend, instead of embed, Python would mean that the main application could be made a Python program. In a simplest form, it could be something like: import Blender; blender</tt>Blender.Application(); blender.main() . That is, if necessary for e.g. performance reasons, the mainloop could still be the current C implementation. Perhaps it could also remain a wholly compiled executable, written in C, even though it would be a Python library at the same time also. But if the functionality it uses is provided to Python, people could relatively easily make their own different applications too. Furthermore, if such refactoring can be done, parts of Blender could be outside of it in other applications as well (e.g. the IPO module might be interesting). But this approach is obviously very problematic and may be practically impossible.


-- ToniAlatalo - 27 Sep 2004