10 #ifndef __PY_Python_h__
11 #define __PY_Python_h__
38 const char *python_code,
40 const char *heading = NULL,
49 const char *python_code,
52 const char *error_heading,
53 const char *error_for_wrong_type,
65 const char *python_code,
67 const char *as_file=
nullptr);
69 const char *python_code,
const char *as_file=
nullptr);
75 const char *python_code,
76 int argc,
char *argv[],
78 bool update_path=
true);
88 const char *python_code,
89 const char *heading = NULL,
91 const char *as_file=
nullptr);
93 const char *python_code,
94 const char *heading = NULL,
95 const char *as_file=
nullptr);
105 int argc,
char *argv[],
107 bool update_path=
true);
116 const char *python_code,
UT_String &errors);
118 const char *file_name,
UT_String &errors);
120 int argc,
char *argv[],
UT_String &errors,
bool update_path=
true);
145 void *opaque_python_object,
const char *method_name,
165 const char *module_name,
const char *module_contents);
179 void (*callback)(
const char *heading,
const char *error_message));
184 const char *heading,
const char *traceback_message);
249 template<
typename FUNC>
254 FUNC
const& process_func )
263 process_func(errmsg.c_str());
PY_API void PYsetAutoInitializeFromPython(bool auto_initialize)
PY_API PY_Result PYextractResultFromPythonObject(void *opaque_python_object, PY_Result::Type desired_result_type)
GT_API const UT_StringHolder filename
PY_API PY_Result PYrunPythonStatementsFromFile(const char *filename, PY_EvaluationContext *context=NULL)
PY_API void PYlogError(PY_Result const &result, const char *title)
PY_API void PYdisplayPythonTraceback(const char *heading, const char *traceback_message)
PY_API bool PYautoInitializeFromPython()
PY_API void * PYgetCodeObjectForFunction(void *opaque_python_object)
Return a PyCodeObject * corresponding to the specified PyObject.
PY_API UT_UniquePtr< UT_Thread > PYrunPythonStatementsFromFileInNewThread(const char *file_name, UT_String &errors)
PY_API PY_Result PYcallMethodOnPythonObject(void *opaque_python_object, const char *method_name, PY_Result::Type desired_result_type)
PY_API UT_String PYgetPythonLibsSubdir()
Returns the Houdini python libs folder name e.g. "python3.7libs".
**But if you need a result
PY_API bool PYrunPythonExpressionOfExactType(const char *python_code, PY_Result::Type desired_result_type, PY_Result &result, const char *error_heading, const char *error_for_wrong_type, PY_EvaluationContext *context=NULL)
PY_API PY_Result PYrunPythonStatementsInNewContext(const char *python_code, const char *as_file=nullptr)
PY_API bool PYrunPythonStatementsAndExpectNoErrors(const char *python_code, const char *heading=NULL, PY_EvaluationContext *context=NULL, const char *as_file=nullptr)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
PY_API void PYregisterAtExitCallback(UT_Function< void(void)> func)
PY_API PY_Result PYrunPythonExpressionAndExpectNoErrors(const char *python_code, PY_Result::Type desired_result_type, const char *heading=NULL, PY_EvaluationContext *context=NULL)
PY_API void PYsetPythonTracebackDisplayCallback(void(*callback)(const char *heading, const char *error_message))
PY_API const char * PYgetErrorFormat()
GLint GLint GLsizei GLint GLenum format
void PYprocessError(PY_Result const &result, const char *title, const char *format, FUNC const &process_func)
PY_API UT_UniquePtr< UT_Thread > PYrunPythonStatementsInNewThread(const char *python_code, UT_String &errors)
std::function< T > UT_Function
PY_API void * PYcallObjectAndCatchCrashes(void *callable)
PY_API PY_Result PYbindFunctionFromModule(const char *module_name, const char *func_name)
PY_API PY_Result PYrunPythonExpressionInNewContext(const char *python_code, PY_Result::Type desired_result_type)
PY_API PY_EvaluationContext & PYgetPythonExpressionEvaluationContext()
PY_API PY_Result PYrunPythonStatements(const char *python_code, PY_EvaluationContext *context=NULL, const char *as_file=nullptr)
PY_API PY_Result PYextractPythonException()
PY_API void PYupdatePythonPath(const UT_StringArray &paths_to_remove=UT_StringArray())
PY_API const char * PYgetHoudiniModulePath()
Returns the absolute path to Houdini's Python modules.
PY_API PY_Result PYimportModuleFromString(const char *module_name, const char *module_contents)
PY_API void * PYgetCodeObjectForPrevFrame()
PY_API UT_StringHolder PYformatError(PY_Result const &result, const char *title, const char *format)
PY_API PY_Result PYrunPythonExpression(const char *python_code, PY_Result::Type desired_result_type, PY_EvaluationContext *context=NULL)
PY_API bool PYrunPythonStatementsInNewContextAndExpectNoErrors(const char *python_code, const char *heading=NULL, const char *as_file=nullptr)