diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-28 13:00:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-28 13:00:04 +0300 |
commit | 98f1d6957eccd3e7fab4274f29ee6a44de154210 (patch) | |
tree | c54dd13e29a47ea32d5d9dd9a1ef84583d9e1f9b /source/blender/python | |
parent | 5f329190c9c2921966217611a3ce61f735ba64ec (diff) |
new python module constants
* bpy.home - result of BLI_gethome()
* bpy.version - BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION
* bpy.version_string, as above, formatted: "%d.%02d (sub %d)"
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 44e3c5a2dd5..5ac3a233e11 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -59,6 +59,7 @@ #include "BLI_fileops.h" #include "BLI_string.h" +#include "BKE_blender.h" #include "BKE_context.h" #include "BKE_text.h" #include "BKE_context.h" @@ -220,6 +221,16 @@ static void bpy_init_modules( void ) PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module); } + /* blender info that wont change at runtime, add into _bpy */ + { + PyObject *mod_dict= PyModule_GetDict(mod); + char tmpstr[256]; + PyModule_AddStringConstant(mod, "_HOME", BLI_gethome()); + PyDict_SetItemString(mod_dict, "_VERSION", Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); + sprintf(tmpstr, "%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); + PyModule_AddStringConstant(mod, "_VERSION_STR", tmpstr); + } + /* add our own modules dir, this is a python package */ bpy_import_test("bpy"); } |