class Env()
Env represents a job’s runtime environment e.g. local files and python dependencies. This class provides functionality to manage Python environments with specific versions, dependencies, and local file inclusions. Arguments:
  • python_version str | None - The Python version to use for this environment. If None, uses the current platform’s Python version.
Attributes:
  • environ MutableMapping[str, str] - A mutable mapping of environment variables which are available in the job.
Examples:
from ev import Env

env = Env("3.11")
env.pip_install("requirements.txt")
env.include("/path/to/local.py")

env.environ["foo"] = "bar"

environ

@property
def environ() -> MutableMapping[str, str]
Returns the environment variable dictionary-like object for this environment. Returns: MutableMapping[str, str]: A mutable mapping containing environment variables for this environment.

environ

@environ.setter
def environ(environ: dict[str, str]) -> None
Sets the environment variables for this environment from the given dictionary. Arguments:
  • environ dict[str, str] - A dictionary containing environment variables to set.
Returns:
  • None - This method does not return anything.

include

@functools.singledispatchmethod
def include(paths: str | list[str]) -> Env
Adds the given file path to this environment, returning itself for chaining. Arguments:
  • paths str | list[str] - The file path(s) to include. Can be a string path or list of string paths.
Returns:
  • Env - Returns this environment instance for method chaining.
Raises:
  • TypeError - If the paths argument is of an unsupported type.

pip_install

@functools.singledispatchmethod
def pip_install(requirements: str | list[str]) -> Env
Adds the requirements to this environment, returning itself for chaining. See: https://pip.pypa.io/en/stable/reference/requirements-file-format/ Arguments:
  • requirements list[str] - The requirements.txt path (str) or a requirements list.
Returns:
  • Env - Returns this environment instance for method chaining.
Raises:
  • TypeError - If the requirements argument is of an unsupported type.