Skip to content

Environment

EnvironmentLink

The sierra.core.environment module handles creation, initialization, and teardown of the on‑disk Sierra development environment—setting up config directories, the virtualenv, scripts folder, and more.

Initializing your Sierra environment
Python
import pathlib
import sierra.core.environment as environment

# Given a SierraDevelopmentClient instance `client`...
project_root = pathlib.Path("/path/to/project")
env = environment.SierraDevelopmentEnvironment(
    client=client,
    name="default_env",            # logical environment name
    path=project_root      # base path for all Sierra files
)

# Create config/, scripts/, venv/, invokers/ directories
env.init()

sierra.core.environment Link

ClassesLink

Environment Link

Bases: typing.TypedDict

AttributesLink
name instance-attribute Link
Python
name: str
path instance-attribute Link
Python
path: pathlib.Path
SierraDevelopmentEnvironment Link
Python
SierraDevelopmentEnvironment(
    client: sierra_client.SierraDevelopmentClient,
    **kwrags: typing.Unpack[Environment],
)

Bases: sierra_core_base.SierraCoreObject

Manages the lifecycle of a SIERRA development environment.

Logs each step to the client's logger.

Initialize a SierraDevelopmentEnvironment.

PARAMETER DESCRIPTION
client

The client instance to use for logging and API interactions.

TYPE: SierraDevelopmentClient

**kwrags

Environment parameters.

TYPE: Environment DEFAULT: {}

AttributesLink
client instance-attribute Link
Python
client = client
name instance-attribute Link
Python
name: str = kwrags.get('name', 'sierra_config')
path instance-attribute Link
Python
path: pathlib.Path = kwrags.get('path', pathlib.Path.cwd())
config_path instance-attribute Link
Python
config_path: pathlib.Path = self.path / self.name
venv_path instance-attribute Link
Python
venv_path: pathlib.Path = self.config_path / 'venv'
scripts_path instance-attribute Link
Python
scripts_path: pathlib.Path = self.config_path / 'scripts'
sierra_env_path instance-attribute Link
Python
sierra_env_path: pathlib.Path = self.config_path
invokers_path instance-attribute Link
Python
invokers_path: pathlib.Path = (
    self.sierra_env_path / "invokers"
)
os_type instance-attribute Link
Python
os_type: str = platform.system().lower()
FunctionsLink
init Link
Python
init() -> None

Initialize the environment.

Logs each step to the client's logger.

destroy Link
Python
destroy() -> None

Remove the environment configuration directory.

Logs each step of the operation.

RAISES DESCRIPTION
OSError

If the directory removal fails.

exists Link
Python
exists() -> bool

Check if the environment configuration directory exists.

RETURNS DESCRIPTION
bool

True if the directory exists.

list_contents Link
Python
list_contents() -> typing.List[str]

List the contents of the environment configuration directory.

RETURNS DESCRIPTION
list of str

List of file names in the configuration directory.

RAISES DESCRIPTION
SierraPathError

If the configuration directory does not exist.

install_dependencies Link
Python
install_dependencies(
    requirements_file: typing.Optional[pathlib.Path] = None,
) -> None

Install dependencies from a requirements file into the virtual environment.

PARAMETER DESCRIPTION
requirements_file

Path to the requirements file. If None or the file does not exist, the installation is skipped.

TYPE: pathlib.Path DEFAULT: None

RAISES DESCRIPTION
SierraExecutionError

If pip is not found in the virtual environment or if the installation of dependencies fails.

activate_instructions Link
Python
activate_instructions() -> str

Generate the command string for activating the virtual environment.

RETURNS DESCRIPTION
str

The activation command string for the appropriate OS environment.

Notes

This function constructs the activation command for virtual environments on both Windows and Unix-like systems.