feat(publish): add --variant and --variant-config flags#6109
Conversation
Lets callers narrow the build matrix from the command line so packages can be parallelized across variants in CI. CLI overrides replace matching keys from the workspace `build-variants`, while `--variant-config` files are appended to the workspace `build-variants-files`. Closes #4877.
Collapse parse_variant cases into success/error tables, replace the duplicate merge helper with a real overlay_cli_variants function used by execute().
Does this also overwrite existing keys if there is a conflict? |
| /// Overlay CLI `--variant` overrides on top of the workspace variants. | ||
| /// Multiple `--variant` flags with the same key accumulate values, but as a | ||
| /// group they replace the matching key from the workspace. | ||
| fn overlay_cli_variants( |
There was a problem hiding this comment.
I would prefer to return instead of having a mutable value.
There was a problem hiding this comment.
Maybe we can have a function that creates a BTreeMap from the arguments and then justs use variant_configuration.extend at the callsite?
| assert_eq!( | ||
| parse_variant("expr=a=b").unwrap(), | ||
| ("expr".into(), vec!["a=b".into()]), | ||
| ); |
There was a problem hiding this comment.
This seems like a mistake? Shouldnt that error?
| } | ||
|
|
||
| #[test] | ||
| fn overlay_cli_variants_replaces_workspace_key_and_accumulates_repeats() { |
There was a problem hiding this comment.
Should we also have tests for variant files?
Address review feedback on #6109: - Replace the &mut overlay helper with cli_variants_map() that returns a BTreeMap, used via variant_configuration.extend() at the callsite. - Reject `=` in variant values so typos like `python=3.12=foo` fail loudly instead of producing a single weird value. - Extract variant-config path resolution into resolve_variant_config_paths() and add a unit test for it. - Regenerate the autogenerated CLI docs for `pixi publish`. - Add example sections to publish_extender covering single-variant builds and `-m` files.
|
Yes — when keys collide, the CLI-supplied I documented this in Generated by Claude Code |
| pixi publish https://prefix.dev/my-channel --clean | ||
| ``` | ||
|
|
||
| ### Building a single variant (parallelizing CI) |
There was a problem hiding this comment.
The parallelziing CI is just one use case for this. We should not mention it as prominent.
There was a problem hiding this comment.
Reframed in 846d0e3 — merged the two variant sections into a single "Overriding build variants" section and moved CI parallelization into a list of motivations in the intro rather than the heading.
Generated by Claude Code
|
|
||
| CLI overrides replace the matching key from the workspace `build-variants`; workspace keys that aren't named on the command line keep their full value list. | ||
|
|
||
| ### Providing additional variant config files |
There was a problem hiding this comment.
I think we can mention that it is preferred to mention the variant config files int he pixi.toml
There was a problem hiding this comment.
Good call — done in 2ea6595. The paragraph now leads with "prefer listing the YAML files in [workspace.build-variants-files] in pixi.toml" and frames -m as the one-off-override path.
Generated by Claude Code
Description
Adds two new flags to
pixi publishso callers can narrow the build matrix from the command line. This is the missing piece for parallelizing a package across its build variants in CI — todaypixi publishalways builds the full matrix.The flags mirror the equivalent options on
rattler-build:--variant KEY=VAL[,VAL...](repeatable) — overrides matching keys from the workspace's[workspace.build-variants]. Repeated uses of the same key accumulate values, but as a group they replace whatever the workspace had for that key. Other workspace keys are left untouched, so passing--variant python=3.12against a workspace withpython = [3.10, 3.11, 3.12]andcuda-version = [12.8, 13.0]still produces both CUDA variants — just only for Python 3.12.--variant-config FILE/-m FILE(repeatable) — appends extra variant-config YAML files after the workspace'sbuild-variants-files. Relative paths resolve against the current working directory.Example from the issue:
The deprecated
pixi buildcommand is intentionally left alone — it'll be redesigned separately.Fixes #4877
How Has This Been Tested?
crates/pixi_cli/src/publish.rscovering:parse_variantsuccess paths (single value, comma-separated values, value containing=)parse_variantrejection of malformed input (missing=, empty key, empty value)overlay_cli_variantsreplacing the matching workspace key, accumulating repeated--variantflags for the same key, and leaving unrelated keys alonecargo check -p pixi_cliandcargo check -p pixi --testspass.cargo test -p pixi_cli --lib publish::— 3/3 pass.cargo fmt/cargo clippyweren't available in the pinned 1.94.0 toolchain in the dev environment; please run them in CI.AI Disclosure
Tools: Claude Code
Checklist:
schema/model.py.Generated by Claude Code