Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-11 11:35:46 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-11 11:36:49 +0400
commitb7b4f94e782f7e74c5acf0af19dfda07fdd92568 (patch)
tree700bcf546c6a40c01998a07ed7fa60e8bb53e8eb /source/blender/freestyle/intern/python/BPy_Freestyle.cpp
parent52a5d58045ae2cc3eccbb936e87054eeb75967e2 (diff)
Fix for Freestyle Python API modules not found in the Python Console.
Addition of the path to the Freestyle Python API modules to 'sys.path' was delayed until the first Freestyle rendering, so that any import attempt of the modules in the Python Console always failed. Now the update of 'sys.path' is done at Blender start-up. This allows the Freestyle-specific modules to be imported without running Freestyle, facilitating quick interactive testing in the Console.
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_Freestyle.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index dee058e6844..64e186b0def 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -485,6 +485,23 @@ PyObject *Freestyle_Init(void)
if (!module)
return NULL;
PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module);
+
+ // update 'sys.path' for Freestyle Python API modules
+ const char * const path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "freestyle");
+ if (path) {
+ char modpath[FILE_MAX];
+ BLI_join_dirfile(modpath, sizeof(modpath), path, "modules");
+ PyObject *sys_path = PySys_GetObject("path"); /* borrow */
+ PyObject *py_modpath = PyUnicode_FromString(modpath);
+ PyList_Append(sys_path, py_modpath);
+ Py_DECREF(py_modpath);
+#if 0
+ printf("Adding Python path: %s\n", modpath);
+#endif
+ }
+ else {
+ printf("Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.\n");
+ }
// attach its classes (adding the object types to the module)