Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/intern/bpy.c
| Show All 24 Lines | |||||
| * | * | ||||
| * This file defines the '_bpy' module which is used by python's 'bpy' package | * This file defines the '_bpy' module which is used by python's 'bpy' package | ||||
| * to access C defined builtin functions. | * to access C defined builtin functions. | ||||
| * A script writer should never directly access this module. | * A script writer should never directly access this module. | ||||
| */ | */ | ||||
| #include <Python.h> | #include <Python.h> | ||||
| #include "CLG_log.h" | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "BKE_global.h" /* XXX, G_MAIN only */ | #include "BKE_global.h" /* XXX, G_MAIN only */ | ||||
| #include "BKE_blender_version.h" | #include "BKE_blender_version.h" | ||||
| #include "BKE_bpath.h" | #include "BKE_bpath.h" | ||||
| Show All 20 Lines | |||||
| #include "bpy_msgbus.h" | #include "bpy_msgbus.h" | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| # include "BPy_Freestyle.h" | # include "BPy_Freestyle.h" | ||||
| #endif | #endif | ||||
| PyObject *bpy_package_py = NULL; | PyObject *bpy_package_py = NULL; | ||||
| static CLG_LogRef LOG = {"bpy.main"}; | |||||
| PyDoc_STRVAR(bpy_script_paths_doc, | PyDoc_STRVAR(bpy_script_paths_doc, | ||||
| ".. function:: script_paths()\n" | ".. function:: script_paths()\n" | ||||
| "\n" | "\n" | ||||
| " Return 2 paths to blender scripts directories.\n" | " Return 2 paths to blender scripts directories.\n" | ||||
| "\n" | "\n" | ||||
| " :return: (system, user) strings will be empty when not found.\n" | " :return: (system, user) strings will be empty when not found.\n" | ||||
| " :rtype: tuple of strings\n" | " :rtype: tuple of strings\n" | ||||
| ); | ); | ||||
| ▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | void BPy_init_modules(void) | ||||
| if (modpath) { | if (modpath) { | ||||
| // printf("bpy: found module path '%s'.\n", modpath); | // printf("bpy: found module path '%s'.\n", modpath); | ||||
| PyObject *sys_path = PySys_GetObject("path"); /* borrow */ | PyObject *sys_path = PySys_GetObject("path"); /* borrow */ | ||||
| PyObject *py_modpath = PyUnicode_FromString(modpath); | PyObject *py_modpath = PyUnicode_FromString(modpath); | ||||
| PyList_Insert(sys_path, 0, py_modpath); /* add first */ | PyList_Insert(sys_path, 0, py_modpath); /* add first */ | ||||
| Py_DECREF(py_modpath); | Py_DECREF(py_modpath); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("bpy: couldnt find 'scripts/modules', blender probably wont start.\n"); | CLOG_WARN(&LOG, "couldnt find 'scripts/modules', blender probably wont start."); | ||||
| } | } | ||||
| /* stand alone utility modules not related to blender directly */ | /* stand alone utility modules not related to blender directly */ | ||||
| IDProp_Init_Types(); /* not actually a submodule, just types */ | IDProp_Init_Types(); /* not actually a submodule, just types */ | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| Freestyle_Init(); | Freestyle_Init(); | ||||
| #endif | #endif | ||||
| mod = PyModule_New("_bpy"); | mod = PyModule_New("_bpy"); | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||