HDK
|
#include "pxr/pxr.h"
#include "pxr/base/tf/api.h"
#include <hboost/python/handle.hpp>
#include <hboost/python/object.hpp>
#include <string>
Go to the source code of this file.
Functions | |
PXR_NAMESPACE_OPEN_SCOPE TF_API void | TfPyInitialize () |
TF_API int | TfPyRunSimpleString (const std::string &cmd) |
TF_API hboost::python::handle | TfPyRunString (const std::string &cmd, int start, hboost::python::object const &globals=hboost::python::object(), hboost::python::object const &locals=hboost::python::object()) |
TF_API hboost::python::handle | TfPyRunFile (const std::string &filename, int start, hboost::python::object const &globals=hboost::python::object(), hboost::python::object const &locals=hboost::python::object()) |
Python runtime utilities.
Definition in file pyInterpreter.h.
PXR_NAMESPACE_OPEN_SCOPE TF_API void TfPyInitialize | ( | ) |
Starts up the python runtime. IMPORTANT: The GIL will NOT be held when this returns. (If Python is already initialized, the GIL will be unchanged)
The program name and arguments are set automatically. sys.argv has no arguments other than an argv[0] matching the program name.
TF_API hboost::python::handle TfPyRunFile | ( | const std::string & | filename, |
int | start, | ||
hboost::python::object const & | globals = hboost::python::object() , |
||
hboost::python::object const & | locals = hboost::python::object() |
||
) |
Runs the given file using PyRun_File().
start is Py_eval_input, Py_single_input or Py_file_input. globals and locals can be dictionaries to use when evaluating the string in python. Defaults to reusing globals from main module. If only the globals are provided, they will also be used as locals.
Starts the interpreter if necessary. Deals with necessary thread state setup.
Callers must hold the GIL before calling; see TfPyLock. This is true for any hboost::python call, including constructing and destroying the default values of globals
and locals
. Holding the GIL will also make it safe to inspect the returned hboost::python::handle.
TF_API int TfPyRunSimpleString | ( | const std::string & | cmd | ) |
Runs the given string using PyRun_SimpleString().
Starts the interpreter if necessary. Deals with necessary thread state setup.
Callers are not required to hold the GIL, though of course they may.
Returns zero on success, nonzero on failure.
TF_API hboost::python::handle TfPyRunString | ( | const std::string & | cmd, |
int | start, | ||
hboost::python::object const & | globals = hboost::python::object() , |
||
hboost::python::object const & | locals = hboost::python::object() |
||
) |
Runs the given string using PyRun_String().
start is Py_eval_input, Py_single_input or Py_file_input. globals and locals can be dictionaries to use when evaluating the string in python. Defaults to reusing globals from main module. If only the globals are provided, they will also be used as locals.
Starts the interpreter if necessary. Deals with necessary thread state setup.
Callers must hold the GIL before calling; see TfPyLock. This is true for any hboost::python call, including constructing and destroying the default values of globals
and locals
. Holding the GIL will also make it safe to inspect the returned hboost::python::handle.