Parsers#
File format parsers and the detection/registry system.
Each parser handles both workspace configuration and task definitions for its file format.
Manifest detection and parser registry (workspaces and tasks).
Search order (same for workspaces and tasks)#
conda.toml– conda-native manifest formatpixi.toml– pixi-native format (compatibility)pyproject.toml– pixi or conda tables embedded
The first file that exists and contains the relevant configuration wins.
- conda_workspaces.parsers.detect_and_parse(start_dir: str | Path | None = None) tuple[Path, WorkspaceConfig][source]#
Detect the workspace manifest and parse it.
Returns
(manifest_path, workspace_config).
- conda_workspaces.parsers.detect_and_parse_tasks(file_path: Path | None = None, start_dir: Path | None = None) tuple[Path, dict[str, Task]][source]#
Detect (or use file_path) a task file and parse it.
Returns
(resolved_path, {task_name: Task}). RaisesNoTaskFileErrorwhen no file is found.
- conda_workspaces.parsers.detect_task_file(start_dir: Path | None = None) Path | None[source]#
Walk up from start_dir looking for a file that contains tasks.
Returns the first match according to
_SEARCH_FILES, orNone.
- conda_workspaces.parsers.detect_workspace_file(start_dir: str | Path | None = None) Path[source]#
Walk up from start_dir to find a workspace manifest.
Returns the path to the first matching file. Raises
WorkspaceNotFoundErrorif none is found.
- conda_workspaces.parsers.find_parser(path: Path) ManifestParser[source]#
Return the parser that can handle path.
Raises
WorkspaceParseErrorif no parser matches.
Abstract base class for manifest parsers (workspaces and tasks).
- class conda_workspaces.parsers.base.ManifestParser[source]#
Interface that every manifest parser must implement.
Each parser handles one file format (
conda.toml,pixi.toml, orpyproject.toml). Subclasses declare which files they can handle via filenames and extensions. The registry inparsers/__init__.pyuses these to auto-detect the right parser.A single parser instance handles both workspace configuration and task definitions from the same file.
- filenames: ClassVar[tuple[str, ...]] = ()#
- abstractmethod has_workspace(path: Path) bool[source]#
Return True if path contains workspace configuration.
- abstractmethod parse(path: Path) WorkspaceConfig[source]#
Parse path and return a
WorkspaceConfig.
- parse_tasks(path: Path) dict[str, Task][source]#
Parse path and return a mapping of task-name to Task.
Parser for conda.toml manifests and shared TOML helpers.
The CondaTomlParser handles conda.toml — the conda-native
manifest format for both workspace configuration and task definitions.
Helper functions for parsing channels, dependencies, environments,
and target overrides are shared with pixi_toml.py and
pyproject_toml.py.
- class conda_workspaces.parsers.toml.CondaTomlParser[source]#
Parse
conda.tomlmanifests (workspace and tasks).This is the conda-native format that mirrors pixi.toml structure but uses
[workspace]exclusively (no[project]fallback).- filenames = ('conda.toml',)#
- parse(path: Path) WorkspaceConfig[source]#
Parse path and return a
WorkspaceConfig.
- conda_workspaces.parsers.toml.tasks_to_toml(tasks: dict[str, Task]) str[source]#
Serialize a full task dict to
conda.tomlTOML string.
Parser for pixi.toml workspace manifests.
Reads [workspace] (or [project] for legacy manifests),
[dependencies], [pypi-dependencies], [feature.*],
[environments], and [target.*] tables from pixi.toml.
- class conda_workspaces.parsers.pixi_toml.PixiTomlParser[source]#
Parse
pixi.tomlmanifests (workspace and tasks).- filenames = ('pixi.toml',)#
- parse(path: Path) WorkspaceConfig[source]#
Parse path and return a
WorkspaceConfig.
Parser for pyproject.toml workspace manifests.
Reads workspace configuration from pyproject.toml, trying these
tables in order:
[tool.conda.workspace]– conda-native table[tool.pixi.workspace]– pixi compatibility
- class conda_workspaces.parsers.pyproject_toml.PyprojectTomlParser[source]#
Parse workspace and task config from
pyproject.toml.Tries these tool tables in priority order:
[tool.conda.*]– conda-native tables[tool.pixi.*]– pixi compatibility
- filenames = ('pyproject.toml',)#
- parse(path: Path) WorkspaceConfig[source]#
Parse path and return a
WorkspaceConfig.
Shared logic for normalizing raw task dicts into Task model objects.
- conda_workspaces.parsers.normalize.normalize_args(raw: list[Any] | None) list[TaskArg][source]#
Convert raw arg definitions into TaskArg objects.
Accepted shapes: -
["name"](required arg, no default) -[{"arg": "name", "default": "value"}]-[{"arg": "name", "default": "value", "choices": ["a", "b"]}]
- conda_workspaces.parsers.normalize.normalize_depends_on(raw: list[Any] | str | None) list[TaskDependency][source]#
Convert the various
depends-onformats into TaskDependency objects.Accepted shapes: -
["foo", "bar"](simple list of task names) -[{"task": "foo", "args": ["x"]}, ...](full dict form) -[{"task": "foo"}, {"task": "bar"}](pixi alias shorthand)
- conda_workspaces.parsers.normalize.normalize_override(raw: dict[str, Any]) TaskOverride[source]#
Parse a raw dict into a TaskOverride.
- conda_workspaces.parsers.normalize.normalize_task(name: str, raw: str | list[Any] | dict[str, Any]) Task[source]#
Convert a single raw task value into a Task object.
Handles all the shorthand forms: -
"command string"(simple string command) -["dep1", "dep2"]or[{"task": ...}](alias / dependency-only) -{cmd: ..., depends-on: ..., ...}(full dict definition)
- conda_workspaces.parsers.normalize.parse_feature_tasks(data: dict[str, Any], tasks: dict[str, Task]) None[source]#
Parse
[feature.<name>.tasks]and their target overrides.Merges feature-scoped tasks into tasks in place. Shared by
PixiTomlParserandPyprojectTomlParser.
- conda_workspaces.parsers.normalize.parse_tasks_and_targets(data: dict[str, Any]) dict[str, Task][source]#
Parse
[tasks]and[target.<platform>.tasks]from a data dict.Shared by
CondaTomlParser,PixiTomlParser, andPyprojectTomlParser— the core parsing logic is identical across all three formats once the root data dict is resolved.