Skip to content

fix: evaluate PyPI extras when walking lockfile dependencies#6068

Merged
ruben-arts merged 1 commit into
prefix-dev:mainfrom
baszalmstra:claude/pixi-list-extras-support-YmLHg
May 11, 2026
Merged

fix: evaluate PyPI extras when walking lockfile dependencies#6068
ruben-arts merged 1 commit into
prefix-dev:mainfrom
baszalmstra:claude/pixi-list-extras-support-YmLHg

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

Description

pixi tree was dropping every PyPI dependency gated by extra == 'X' because it filtered requires_dist with marker.is_true() and no extras context. For e.g. crc-bonfire[cli] this hid ocviapy, truststore, click, and the rest of the cli subtree.

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, matching uv tree's (extra: <name>) style. Top-level deps are sorted so output is deterministic. Falls back to the previous is_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 over examples/{editable-with-extras,pypi} drive the production printer against the checked-in lockfiles (no solve, no network) and verify activator annotations on both package_with_extras[cli,color] and black[jupyter]. Manual repro of #6054 confirms the missing cli subtree now shows up correctly tagged.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code

Checklist:

  • I have performed a self-review of my own code
  • I have added sufficient tests to cover my changes.

@baszalmstra baszalmstra force-pushed the claude/pixi-list-extras-support-YmLHg branch from 2c2182a to 7b03385 Compare May 11, 2026 09:23
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
@baszalmstra baszalmstra force-pushed the claude/pixi-list-extras-support-YmLHg branch from 7b03385 to bf09610 Compare May 11, 2026 09:43
@baszalmstra
Copy link
Copy Markdown
Contributor Author

@ruben-arts If CI succeeds then this is ready too!

Copy link
Copy Markdown
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

Nice one!

@ruben-arts ruben-arts merged commit b189316 into prefix-dev:main May 11, 2026
37 checks passed
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.

pixi tree doesn't list all pypi dependencies (installed from extra features)

3 participants