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)"
This commit is contained in:
2009-12-28 10:00:04 +00:00
parent 5f329190c9
commit 98f1d6957e
5 changed files with 22 additions and 29 deletions

View File

@@ -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");
}