Snex.Interpreter (Snex v0.1.0)

View Source

Runs a Python interpreter in a separate OS process.

This module is responsible for facilitating in-and-out communication between Elixir and the spawned Python interpreter.

Usually you won't interact with this module directly. Instead, you would create a custom interpreter module with use Snex.Interpreter:

defmodule SnexTest.NumpyInterpreter do
  use Snex.Interpreter,
    pyproject_toml: """
    [project]
    name = "my-numpy-project"
    version = "0.0.0"
    requires-python = "==3.11.*"
    dependencies = ["numpy>=2"]
    """
  end

See the Snex module documentation for more detail.

Summary

Types

Options for start_link/1.

Running instance of Snex.Interpreter.

Functions

Returns a specification to start this module under a supervisor.

Starts a new Python interpreter.

Types

option()

@type option() ::
  {:python, String.t()}
  | {:environment, %{optional(String.t()) => String.t()}}
  | GenServer.option()

Options for start_link/1.

server()

@type server() :: GenServer.server()

Running instance of Snex.Interpreter.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])

@spec start_link([option()]) :: GenServer.on_start()

Starts a new Python interpreter.

The interpreter can be used by functions in the Snex module.

Options

  • :python - The Python executable to use. This can be a full path or a command to find via System.find_executable/1.
  • :environment - A map of environment variables to set when running the Python executable.
  • any other options will be passed to GenServer.start_link/3.