Skip to content

feat: add the conda-script block model to pixi_manifest - #6907

Open
Hofer-Julian wants to merge 1 commit into
mainfrom
conda-script-parser
Open

feat: add the conda-script block model to pixi_manifest#6907
Hofer-Julian wants to merge 1 commit into
mainfrom
conda-script-parser

Conversation

@Hofer-Julian

@Hofer-Julian Hofer-Julian commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

The /// conda-script comment block (#3751) parsed as a script manifest next to the PEP 723 one.

  • pixi_manifest::script splits into machinery both block kinds share (comment-prefix stripping, source maps for diagnostics, serializing edits back into the block) and one submodule per kind
  • TOML model: channels, entrypoint (string or platform table), [dependencies], [tool.pixi] with dependencies and pypi-dependencies
  • [dependencies] rejects pixi-build specs (git, path, a url that is not a conda archive)
  • Errors for unterminated blocks, multiple blocks and files mixing a PEP 723 block with a conda-script block

@Hofer-Julian Hofer-Julian changed the title conda script parser feat: add the pixi_conda_script crate with the block parser and TOML model Aug 27, 2026
@Hofer-Julian
Hofer-Julian force-pushed the conda-script-parser branch 2 times, most recently from fe4a43d to 9d4a9b3 Compare August 27, 2026 15:30
@Hofer-Julian Hofer-Julian changed the title feat: add the pixi_conda_script crate with the block parser and TOML model feat: add the conda-script block model to pixi_manifest Aug 31, 2026
@Hofer-Julian
Hofer-Julian force-pushed the conda-script-parser branch 2 times, most recently from 057ca70 to aa105fe Compare August 31, 2026 11:49
@Hofer-Julian
Hofer-Julian marked this pull request as ready for review August 31, 2026 12:43
@Hofer-Julian
Hofer-Julian force-pushed the conda-script-parser branch 2 times, most recently from 965e65f to 412b5aa Compare September 3, 2026 12:35

@hunger hunger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feeling is that how files with several blocks are not going to get handled too well, but that is a corner-case you probably won't run into often, so I did not want to spend too much time on that.

I did not look into that too deeply, maybe you can ask your agent to validate that bit a bit deeper.

Err(_) => {
errors.errors.push(custom_error(
format!(
"'{name}' is neither a platform family (`unix`, `linux`, `osx`, `win`) nor a conda platform"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a conda platform? A subdir?

You are passing the name to the output without any sanitization, ESC codes and all.

}

let path = std::path::absolute(path)?;
let source: Arc<str> = Arc::from(std::str::from_utf8(contents)?);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You require the entire file to be utf8 encoded here if I read that correctly. Not all languages require their source code to be utf-8, so that might cause problems.

let mut name_spans: IndexMap<Name, toml_span::Span> = IndexMap::new();
for (key, mut value) in table.into_iter().sorted_by_key(|(key, _)| key.span.start) {
let name = match Name::from_str(&key.name) {
Ok(name) => name,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC empty Names are Ok, you probably do not want those though.

let mut errors = DeserError { errors: Vec::new() };

let channels = th
.required_s::<Vec<TomlFromStr<NamedChannelOrUrl>>>("channels")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can end up with empty channels in the list here...

The first piece of the `conda-script` proposal (#3751): the
`/// conda-script` comment block parsed as a script manifest next to the
PEP 723 one. `script::block` holds the machinery both kinds share:
comment-prefix stripping, source maps for diagnostics and serializing
edits back into the block.

The model covers `channels`, `entrypoint` (string or platform table),
`[dependencies]` restricted to the keys the spec defines, and
`[tool.pixi]` with `dependencies` and `pypi-dependencies`. Edits
round-trip: `metadata_document` exposes the block as TOML and
`write_metadata` writes it back through the comment prefix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants