PyAPI: suppress 'bgl' warning for Blender as a Python module

This would print whenever 'bpy' was imported, because in this case
Blender's Python integration loads all modules immediately because it
can't import modules as needed via the inittab mechanism.

Also correct code-comments for why inittab can't be used.
This commit is contained in:
Campbell Barton
2023-05-30 11:45:21 +10:00
parent 0a125fccf4
commit f6d5a9080b
3 changed files with 18 additions and 4 deletions

View File

@@ -459,14 +459,18 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
Py_DECREF(PyImport_ImportModule("threading"));
# endif
#else
#else /* WITH_PYTHON_MODULE */
(void)argc;
(void)argv;
/* must run before python initializes */
/* broken in py3.3, load explicitly below */
/* NOTE(ideasman42): unfortunately the `inittab` can only be used
* before Python has been initialized.
* When built as a Python module, Python will have been initialized
* and using the `inittab` isn't supported.
* So it's necessary to load all modules as soon as `bpy` is imported. */
// PyImport_ExtendInittab(bpy_internal_modules);
#endif
#endif /* WITH_PYTHON_MODULE */
bpy_intern_string_init();