pipdeptree
pipdeptree copied to clipboard
Option to limit depth of the dependency tree shown
It would be nice to have an option -d N
or --depth N
to limit the depth of the tree shown either in direct dependencies or reverse.
This would also help to find packages left behind when other packages are removed (leaves).
Sounds like a good feature. But didn't understand the use case correctly. You mean before removing a package, it can be used for finding out which dependencies will be left behind?
I mean to find packages without reverse dependencies that can be removed.
Using pipdeptree -r -a
produces a vey long list (hundreds of lines) which is not simple to inspect visually.
pipdeptree -r -a -d 1
would be useful here. If a package shows no rev-deps and is not useful by itself, it can be removed.
Something equivalent to this:
pipdeptree -r -a | grep -v "^[ ]\{4,4\}"
It would also simplify one of the best (to me at least) usage of pipdeptree
which is nothing more than doing pipdeptree -f --warn silence | grep -P '^[\w0-9\-=.]+' > requirements.txt
.
pipdeptree -f -d 1
would simplify it a very very lot.
this will list installed packages that are not dependencies of another installed package: (use ripgrep & sed)
pipdeptree --r -a | rg -U "^[^ ].*\n[^ ].*\n" | sed -n "p;n"
+1 for this.
@gaborbernat We should close this as its been resolved in v2.9.0.