Experimental option to build blender as a python module, rather then blender embedding python.

CMake build option WITH_PYTHON_MODULE, will build ./bin/bpy.so

This allows 'bpy' to be imported from python or other applications/IDE's which embed python, eg:
   python -c "import bpy ; bpy.ops.render.render(write_still=True)"

This runs in background mode and has similar restrictions to running a script:
   blender --background --python test.py

TODO:
 - install to site-packages with blender scripts
 - add support for imp.reload()
This commit is contained in:
Campbell Barton
2011-02-20 23:39:29 +00:00
parent 55a0e21a03
commit c30149991c
9 changed files with 114 additions and 15 deletions

View File

@@ -127,8 +127,21 @@ if(WITH_BUILDINFO)
endif()
# message(STATUS "Configuring blender")
if(WITH_PYTHON_MODULE)
add_definitions(-DWITH_PYTHON_MODULE)
add_executable(blender ${EXETYPE} ${SRC})
# creates ./bin/bpy.so which can be imported as a python module.
add_library(blender SHARED ${SRC})
set_target_properties(
blender
PROPERTIES
PREFIX ""
OUTPUT_NAME bpy
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
)
else()
add_executable(blender ${EXETYPE} ${SRC})
endif()
# Post build steps for bundling/packaging.