fix: evaluate PyPI extras when walking lockfile dependencies#6068
Merged
ruben-arts merged 1 commit intoMay 11, 2026
Merged
Conversation
2c2182a to
7b03385
Compare
Fixes prefix-dev#6054. `pixi tree` filtered PyPI `requires_dist` entries with `marker.is_true()` and no extras context, so dependencies gated by `extra == 'X'` were silently dropped. For `crc-bonfire[cli]` this hid the entire `cli` subtree (`ocviapy`, `truststore`, `click`, ...). Build a PEP 508 marker environment from the locked Python record and propagate activated extras transitively from manifest direct deps through `requires_dist` to a fixed point. Evaluate each requirement with `req.evaluate_markers(env, &extras)` and annotate each edge with the parent extras that activated it, matching `uv tree`'s `(extra: <name>)` style. Falls back to `marker.is_true()` when no Python is locked. Conda matchspec extras (`foo[extras=[bar]]`) are out of scope here; rattler-lock doesn't yet expose per-package activated extras for conda. Other changes: * Generalize the tree printers to `&mut impl Write` so tests can render through the production code path. * Sort the top-level direct deps before printing so output is deterministic across runs (previously iterated a `HashSet`). * Use `PackageName::from_matchspec_str_unchecked` for conda dep name extraction. * Add insta-glob snapshot tests over `examples/editable-with-extras` and `examples/pypi` driving the production printer against the checked-in lockfiles. https://claude.ai/code/session_01JQ8jU14tazjWSYKup6RUuF
7b03385 to
bf09610
Compare
Contributor
Author
|
@ruben-arts If CI succeeds then this is ready too! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pixi treewas dropping every PyPI dependency gated byextra == 'X'because it filteredrequires_distwithmarker.is_true()and no extras context. For e.g.crc-bonfire[cli]this hidocviapy,truststore,click, and the rest of theclisubtree.This PR builds a PEP 508 marker environment from the locked Python and propagates activated extras transitively from the manifest direct deps through
requires_dist. Each edge is then annotated with the parent extras that activated it, matchinguv tree's(extra: <name>)style. Top-level deps are sorted so output is deterministic. Falls back to the previousis_true()filter when no Python is locked.Conda matchspec extras (
foo[extras=[bar]]) are out of scope, left for a follow-up!Fixes #6054
How Has This Been Tested?
insta::glob!snapshot tests overexamples/{editable-with-extras,pypi}drive the production printer against the checked-in lockfiles (no solve, no network) and verify activator annotations on bothpackage_with_extras[cli,color]andblack[jupyter]. Manual repro of #6054 confirms the missingclisubtree now shows up correctly tagged.AI Disclosure
Tools: Claude Code
Checklist: