pipdeptree icon indicating copy to clipboard operation
pipdeptree copied to clipboard

Option to limit depth of the dependency tree shown

Open miguelbarao opened this issue 6 years ago • 4 comments

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).

miguelbarao avatar Jan 18 '18 12:01 miguelbarao

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?

naiquevin avatar Jan 24 '18 11:01 naiquevin

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\}"

miguelbarao avatar Jan 24 '18 14:01 miguelbarao

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.

mumrau avatar Nov 13 '18 08:11 mumrau

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"

clysto avatar Dec 20 '20 16:12 clysto

+1 for this.

mon-jai avatar Mar 19 '23 14:03 mon-jai

@gaborbernat We should close this as its been resolved in v2.9.0.

kemzeb avatar Jul 10 '23 20:07 kemzeb