Skip to content

refactor(pixi_spec): allow v3 matchspec selectors for source dependencies - #6234

Closed
Hofer-Julian wants to merge 4 commits into
prefix-dev:mainfrom
Hofer-Julian:claude/bold-mccarthy-aYhrj
Closed

Hofer-Julian wants to merge 4 commits into
prefix-dev:mainfrom
Hofer-Julian:claude/bold-mccarthy-aYhrj

Conversation

@Hofer-Julian

@Hofer-Julian Hofer-Julian commented May 28, 2026 •

Copy link
Copy Markdown
Member

Allow v3 matchspec selectors for source dependencies. Refactors PixiSpec along the way.

This enables extras, flags and when to work with source dependencies.
Also, recursive source dependencies work.

Example 1:

[dependencies]
example-rust = { path = ".", extras = ["wolf", "julian"]}

[package]
name = "example-rust"
version = "0.1.0"

[package.build]
backend = { name = "pixi-build-rust", version = "*"  }

[package.extra-dependencies.wolf]
rust = "*"
example-rattler-build = { path = "./recipe/recipe.yaml" }

[package.target.win-64.extra-dependencies.julian]
python = "*"

Example 2:

[dependencies]
example-rust = { path = ".", flags = ["cuda"] }

[package]
name = "example-rust"
version = "0.1.0"

[package.build]
backend = { name = "pixi-build-rust", version = "*"  }
flags = ["cuda", "blas_openblas"]

Example 3:

[dependencies]
example-rust = { path = "." }
python = "3.13"

[package]
name = "example-rust"
version = "0.1.0"

[package.build]
backend = { name = "pixi-build-rust", version = "*"  }

[package.run-dependencies]
numpy = { version = "*", when = { package = "python", version = ">=3.12" } }

@Hofer-Julian

Hofer-Julian commented May 28, 2026 •

Copy link
Copy Markdown
Member Author

Need to address comments from #6184

@Hofer-Julian
Hofer-Julian force-pushed the claude/bold-mccarthy-aYhrj branch 8 times, most recently from 1fab6ae to 2050c4f Compare May 29, 2026 14:43
@Hofer-Julian
Hofer-Julian changed the base branch from claude/bold-mccarthy-aYhrj to main May 29, 2026 14:56
@Hofer-Julian
Hofer-Julian force-pushed the claude/bold-mccarthy-aYhrj branch 2 times, most recently from ca5dc99 to 17517cd Compare June 1, 2026 07:32
@ruben-arts

Copy link
Copy Markdown
Contributor

I found an issue through the example that I added in this commit.

If you have extras defined and those dependencies are not satisfied by the workspace already it assumes the lockfile is out of sync as it doesn't take the extra dependencies into account.

It does satisfy if I remove the extras = ["py"] from the example.

@ruben-arts

Copy link
Copy Markdown
Contributor

I still have the issue with the unsatisfiable environment, running pixi lock will always be unsatisfiable on the v3 example.

I also found weird behavior with solving times so I hyperfined the v3 example:

  xychart-beta
      title "pixi lock — run times with mean & median (s)"
      x-axis "Run #" [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
      y-axis "Time (s)" 0 --> 12
      bar [0.115, 5.18, 2.102, 0.477, 0.454, 0.123, 0.167, 0.227, 0.176, 0.335, 0.297, 0.221, 1.561, 1.861, 0.118, 6.487, 3.484, 0.114, 5.378, 0.144, 0.628, 0.133, 11.285, 4.959, 4.948]
      line [2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039]
      line [0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454]
Loading

The command was : hyperfine -w 1 pixi lock

There are loads of really large outliers.

@Hofer-Julian

Copy link
Copy Markdown
Member Author

I still have the issue with the unsatisfiable environment, running pixi lock will always be unsatisfiable on the v3 example.

I also found weird behavior with solving times so I hyperfined the v3 example:

  xychart-beta
      title "pixi lock — run times with mean & median (s)"
      x-axis "Run #" [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
      y-axis "Time (s)" 0 --> 12
      bar [0.115, 5.18, 2.102, 0.477, 0.454, 0.123, 0.167, 0.227, 0.176, 0.335, 0.297, 0.221, 1.561, 1.861, 0.118, 6.487, 3.484, 0.114, 5.378, 0.144, 0.628, 0.133, 11.285, 4.959, 4.948]
      line [2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039, 2.039]
      line [0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454, 0.454]
Loading

The command was : hyperfine -w 1 pixi lock

There are loads of really large outliers.

That's weird. Thanks for double-checking.

I will take a look

@ruben-arts

Copy link
Copy Markdown
Contributor

Thanks, don't hesitate to drag in @baszalmstra as this v3 feature is touch the solver. Maybe it's not this code change but on the rattler/resolve part.

@Hofer-Julian
Hofer-Julian force-pushed the claude/bold-mccarthy-aYhrj branch 8 times, most recently from a61fe1d to af5bc15 Compare June 2, 2026 14:47
Hofer-Julian and others added 4 commits June 3, 2026 10:56
…source types

Let source-side specs carry the v3 matchspec selectors (`extras`,
`flags`, `when`) so source dependencies can participate in v3 resolution
on equal footing with binary ones.

Until now `PixiSpec` only modeled binary matchspec fields, so a git,
url-source, or path-source dependency could not request optional
`[extras]`, gate on `flags`, or be conditioned by a `when` clause - the
v3 selectors had nowhere to live on a source spec, and there was no
type-level distinction between "url pointing at a built archive" and
"url pointing at a source tree" to attach them to.

Splitting `PixiSpec` into `Detailed`, `UrlBinary`, `PathBinary`,
`UrlSource`, `PathSource`, and `Git` puts the binary-vs-source choice
in the type system and gives the three source variants an optional
`MatchspecFields` carrying exactly the subset that applies post-build:
`version`, `build`, `build-number`, `extras`, `flags`, `subdir`,
`license`, `license-family`, `condition` (parsed from `when`), and
`track-features`. Binary-only fields (`channel`, `md5`, `sha256`,
`file-name`) stay on the binary variants where they belong.

With that in place, manifests can write things like a git source with
`extras = ["test"]` or a `when` condition, and the v3 solver sees the
same selector shape regardless of whether the spec resolves from a
channel or from a source build.

test(source): end-to-end extras and source-on-source dependency tests

Make the passthrough build backend surface a source package's declared
`[package.extra-dependencies]` groups in its conda outputs, mirroring how
build/host/run dependencies are already extracted from the project model.

Add end-to-end tests covering: selecting an extra group on a source
dependency (and the negative case), and a source package depending on
another source package through its run-dependencies.


fix: resolve source dependencies declared inside extra groups

A source spec placed in [package.extra-dependencies.<group>] of a source
package was not threaded through source resolution, leaving the inner
package unbuilt and tripping a resolvo assertion when the group was
selected via extras.
The source-record satisfiability check verified run-depends and
run-constrains drift against the backend, but never compared the
optional-dependency groups (extras). A manifest edit to an extra group
left the lock file considered satisfied, so the stale extras were never
re-locked.

Re-derive the backend extras through the same pin-compatibility map and
match-spec stringification the solve path uses, then compare each group
against the locked record. Mismatches surface as a new
SourceExtraDependenciesChanged unsat naming the group and the
added/removed specs.

Adds an experimental_extra_depends accessor on the source record and unit
tests covering matching extras, group addition, group removal, and a
within-group spec change.
@Hofer-Julian
Hofer-Julian force-pushed the claude/bold-mccarthy-aYhrj branch from af5bc15 to 96f74ad Compare June 3, 2026 08:59
@Hofer-Julian

Copy link
Copy Markdown
Member Author

Superseded by stacked PRs

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