|
Python runtime utilities. More...
Go to the source code of this file.
Functions | |
TF_API void | TfPyInitialize () |
Starts up the python runtime. | |
TF_API int | TfPyRunSimpleString (const std::string &cmd) |
Runs the given string using PyRun_SimpleString(). | |
TF_API pxr_boost::python::handle | TfPyRunString (const std::string &cmd, int start, pxr_boost::python::object const &globals=pxr_boost::python::object(), pxr_boost::python::object const &locals=pxr_boost::python::object()) |
Runs the given string using PyRun_String(). | |
TF_API pxr_boost::python::handle | TfPyRunFile (const std::string &filename, int start, pxr_boost::python::object const &globals=pxr_boost::python::object(), pxr_boost::python::object const &locals=pxr_boost::python::object()) |
Runs the given file using PyRun_File(). | |
Python runtime utilities.
Definition in file pyInterpreter.h.
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 pxr_boost::python::handle TfPyRunFile | ( | const std::string & | filename, |
int | start, | ||
pxr_boost::python::object const & | globals = pxr_boost::python::object() , |
||
pxr_boost::python::object const & | locals = pxr_boost::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 pxr_boost::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 pxr_boost::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 pxr_boost::python::handle TfPyRunString | ( | const std::string & | cmd, |
int | start, | ||
pxr_boost::python::object const & | globals = pxr_boost::python::object() , |
||
pxr_boost::python::object const & | locals = pxr_boost::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 pxr_boost::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 pxr_boost::python::handle.