Context#
Lazy workspace context for conda state and platform introspection.
Workspace context — lazy properties for conda & workspace state.
Provides a namespace of lazily-evaluated properties that downstream code can use without importing conda at module level. This keeps import-time overhead negligible.
- class conda_workspaces.context.CondaContext(manifest_path: Path | None = None)[source]#
Lazy-evaluated namespace exposed as
conda.*in task templates.Attribute access is deferred so conda internals load only when a template references a variable.
- property environment: _EnvironmentProxy#
Allows
{{ conda.environment.name }}in templates.
- property environment_name: str#
Name of the currently active conda environment, or
"base".
- property init_cwd: str#
The working directory at the time of context creation.
- property is_linux: bool#
True when the host platform is Linux.
- property is_osx: bool#
True when the host platform is macOS.
- property is_unix: bool#
True when running on a Unix-like system (Linux or macOS).
- property is_win: bool#
True when running on Windows.
- property manifest_path: str#
Path to the task definition file, or empty string if unknown.
- property platform: str#
The conda platform/subdir string, e.g.
linux-64orosx-arm64.
- property prefix: str#
Absolute path to the target conda environment prefix.
- property version: str#
The installed conda version string.
- class conda_workspaces.context.WorkspaceContext(config: WorkspaceConfig | None = None)[source]#
Lazy-evaluated context for the current workspace.
Properties are resolved on first access and cached. Conda imports are deferred to keep plugin load time under 1 ms.
- property config: WorkspaceConfig#
The parsed workspace configuration.
- property envs_dir: Path#
Directory where project-local environments are stored.
- property platform: str#
Current conda subdir (e.g.
osx-arm64).
- property root: Path#
Workspace root directory.
- property root_prefix: Path#
Conda root prefix (base environment).
- conda_workspaces.context.build_template_context(manifest_path: Path | None = None, task_args: dict[str, str] | None = None) dict[str, object][source]#
Build the full Jinja2 template context dict.
The returned dict contains: -
conda: aCondaContextinstance -pixi: alias to the same context (for pixi.toml compatibility) - Any user-supplied task argument values