PR #132 and additional commits on top of it#138
Closed
Conversation
This handles the case where the same package is part of 2 different
extra_require profiles for eg.
{'rsa': ['cryptography'],
'signals': ['blinker'],
'signedtoken': ['cryptography', 'pyjwt>=1.0.0']}
The above is the extra_require dict for oauthlib. Since 'cryptography'
is an extra require in multiple profiles, this caused duplicate
ReqPackage objects to be present in the tree.
As a result of deduplicating, no additional filtering is required in
presentation logic (ie. 'render_text' and 'dump_graphviz' functions).
If a package is specified using the '-p' option and it also happens to be one of the dependencies of another package (also specified as part of '-p' option), then the top level package itself is skipped from the output. For eg. consider following call $ pipdeptree -p 'abc,tox' Now if 'tox' also happens to be the dependency of 'abc', then it's not shown in the output unless '-a' flag (show all) is also specified. This seems to be an old bug that has surfaced now with support for extra requirements. There are cases where a package can be a dependent of itself via extra requirements eg. tox depends on pluggy and pluggy[dev] also depends on tox.
108ca75 to
beacb88
Compare
A lot of code has been refactored in this commit
* master: Fix github checks due to set-env deprecation Shield newline symbol when generating labels for graphviz
Member
|
Seems we'll no longer proceed with this. |
Contributor
Author
|
@gaborbernat This PR was for #107. IIRC, this code was mostly working but as it is an intrusive change I wanted to do a beta release first. Never got to it. It's unlikely that I'll be working on it any time soon but JFYI because the PR is closed whereas issue #107 is still open. If anyone wants to pursue the functionality, this PR can be a good starting point. |
|
I am sorry, I would like to help, but I no longer need this functionality and I have no time to continue working on it. |
gaborbernat
added a commit
that referenced
this pull request
Mar 7, 2026
`pipdeptree` has long ignored extra/optional dependencies defined via PEP 508 `extra` markers. When a user installs a package with extras (e.g. `pip install jira[signedtoken]`), the extra dependencies appear as unrelated top-level packages instead of showing up as children in the dependency tree. This has been a recurring pain point since issue #107 was opened, and previous attempts (#132, #138) were never merged. The new `--extras` / `-x` flag enables transitive resolution of extras in the dependency tree. 🔍 It works by collecting extras from requirement specifiers (e.g. `oauthlib[signedtoken]`), evaluating PEP 508 markers with the correct extras context via `marker.evaluate({"extra": name})`, and iterating until no new extras are discovered. Root packages (those not depended on by anything else) automatically include all their provided extras where the dependency is actually installed. Each extra dependency is annotated with its extra name across all output formats — text shows `extra: signedtoken`, JSON includes an `"extra"` field, and graphviz/mermaid prefix edge labels with `[signedtoken]`. The flag is off by default to preserve backward compatibility. No existing behavior changes when `--extras` is not passed. The `from_pkgs` constructor gained a keyword-only `include_extras` parameter, and the extras resolution runs as a separate pass after the base DAG is built, keeping the core construction logic clean.
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.
No description provided.