pyto_runtime

This is the Python API for PytoRuntime, usable from the runtime itself to manage other versions or interpreters.

Interpreter

APIs for running and debugging scripts.

pyto_runtime.current_interpreter

Returns the current thread's active interpreter or throws a RuntimeError.

pyto_runtime.Interpreter

Interpreter holds configurations, context and debugging tools for scripts execution.

pyto_runtime.Interpreter.version

Embedded Python version to load.

pyto_runtime.Interpreter.running

Indicates whether a script is running under this interpreter.

pyto_runtime.Interpreter.working_directory

The working directory.

pyto_runtime.Interpreter.virtual_environment_home_path

The home URL of a virtual environment that is entered when running a script.

pyto_runtime.Interpreter.standard_output

The standard output text stream.

pyto_runtime.Interpreter.standard_error

The standard error text stream.

pyto_runtime.Interpreter.standard_input

The standard input text stream.

pyto_runtime.Interpreter.receive_view_controller

Function responsible of presenting an UI.

pyto_runtime.Interpreter.receive_image_output

Function responsible of showing images from PIL, Matplotlib or OpenCV.

pyto_runtime.Interpreter.builtins

The builtins module.

pyto_runtime.Interpreter.breakpoints

Breakpoints to set before running a script with debug enabled.

pyto_runtime.Interpreter.breakpoint_handler

Called when a breakpoint is hit and the REPL is entered.

pyto_runtime.Interpreter.display_hook

If set, expressions in the executed script will pass the string representation of their result to this block.

pyto_runtime.Interpreter.trace

if set, a tracer will call this block every time a line of code is about to be executed.

pyto_runtime.Interpreter.evaluate

Evaluates an expression and returns its result wrapped in a pyto_runtime.Object.

pyto_runtime.Interpreter.exec

Executes code and returns a new global namespace in which it was executed, wrapped in a pyto_runtime.Object.

pyto_runtime.Interpreter.import

Imports a module and returns it wrapped in a pyto_runtime.Object.

pyto_runtime.Interpreter.run_path

Runs a script.

pyto_runtime.Interpreter.run_repl

Runs the REPL.

pyto_runtime.Interpreter.run_shell

Runs the shell.

pyto_runtime.Interpreter.run_code

Runs code.

pyto_runtime.Interpreter.kill

Sends a signal the interpreter's main thread and to its pseudo subprocesses threads.

pyto_runtime.Interpreter.end_of_file

Raises an EOFError if reading from standard input (simulates Ctrl+D).

pyto_runtime.Interpreter.clear_state

Clears the state of the interpreter.

pyto_runtime.Interpreter.focus

If a curses script is executing through curses.wrapper in this interpreter, this function sets the global terminal instance.

pyto_runtime.Object

A class wrapping a Python object from pyto_runtime.Interpreter.

pyto_runtime.InterpreterException

An exception raised from an pyto_runtime.Interpreter.

pyto_runtime.InterpreterException.type

pyto_runtime.InterpreterException.args

Version

APIs for loading Python versions.

pyto_runtime.find_versions

Returns a list of Python versions installed in a bundle.

pyto_runtime.Version

A Python version.

pyto_runtime.Version.bundle_path

The path of the Python framework bundle.

pyto_runtime.Version.main_bundle_path

The bundle in which the Python version was found.

pyto_runtime.Version.string

The Python '<major>.<minor>.<micro>' version string retrieved from Info.plist.

pyto_runtime.Version.full_version_string

The full version string (fetched from full_version.txt in the framework bundle).

pyto_runtime.Version.major

Major version.

pyto_runtime.Version.minor

Minor version.

pyto_runtime.Version.micro

Micro release.

pyto_runtime.Version.alpha

Alpha release.

pyto_runtime.Version.beta

Beta release.

pyto_runtime.Version.rc

Rc release.

pyto_runtime.Version.end_of_life

Indicates whether the version was compiled from an end of life branch.

Debugging

Classes for debugging.

pyto_runtime.Breakpoint

Represents a breakpoint.

pyto_runtime.Breakpoint.path

The script paht.

pyto_runtime.Breakpoint.lineno

The line number.

pyto_runtime.Breakpoint.enabled

Indicates whether the breakpoint should be triggered or not.

pyto_runtime.Breakpoint.line

The contents of the line.

pyto_runtime.Traceback

A serialized traceback.

pyto_runtime.Traceback.exc_type

A string describing the type of the exception.

pyto_runtime.Traceback.msg

The receiver's message string.

pyto_runtime.Traceback.stack

A pre-loaded list containing every frame serialized as pyto_runtime.Frame objects.

pyto_runtime.Traceback.as_text

The stack trace as a string.

pyto_runtime.Traceback.name

If AttributeError or NameError, the name that caused the error.

pyto_runtime.Traceback.suggestion

If AttributeError or NameError, a suggestion to fix the error.

pyto_runtime.Traceback.offset

If SyntaxError, the beggining start position of the concerned code.

pyto_runtime.Traceback.end_offset

If SyntaxError, the end position of the concerned code.

pyto_runtime.Frame

A serialized frame from a pyto_runtime.Traceback.

pyto_runtime.Frame.file_path

The file path.

pyto_runtime.Frame.lineno

The line number.

pyto_runtime.Frame.line

The contents of the line.

pyto_runtime.Frame.name

The name of the current function or namespace.

pyto_runtime.Frame.index

The index in relation to its sibling frames.

pyto_runtime.Frame.globals

A reference to the globals dictionary wrapped in a pyto_runtime.Object.

pyto_runtime.Frame.locals

A reference to the locals dictionary wrapped in a pyto_runtime.Object.

Swift Extensions

Classes for working with Swift Extensions. pyto_runtime.SwiftFinder is automatically added to sys.meta_path by every interpreter.

See Extensions for more information.

pyto_runtime.SwiftError

A type representing an Error raised by a Swift function.

pyto_runtime.SwiftError.type

pyto_runtime.SwiftError.description

pyto_runtime.SwiftFinder

A meta path finder for finding Swift modules registered by the interpreter.

pyto_runtime.SwiftLoader

A module loader for importing Swift modules registered by the interpreter.