tox-dev / pipdeptree

A command line utility to display dependency tree of the installed Python packages

Home Page:https://pypi.python.org/pypi/pipdeptree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing dependencies

Or-Geva opened this issue · comments

I have the following requirements.txt file:

django-debug-toolbar==1.4
django==1.9.5

After running pipdeptree i get the following:

django-debug-toolbar==1.4
├── Django [required: >=1.7, installed: 1.9.5]
└── sqlparse [required: Any, installed: 0.4.4]
pip==23.2.1
pipdeptree==2.12.0
setuptools==58.0.4

Shouldn't I see Django listed at level 0 similar to django-debug-toolbar?

It would have been there, but because of this code:

if not list_all:
nodes = [p for p in nodes if p.key not in branch_keys]

Django will be seen as a dependency of django-debug-toolbar (just like sqlparse), and therefore will not add them at depth 0 in the output. Due of this behavior, it won't matter if you include Django in your requirements.txt as it will give you the same output without it. To add Django (and in effect sqlparse and any other packages' dependencies) as top-level packages, you could pass the -a option.

I'm not sure of a way (either using pip's API or somehow manipulating the PackageDAG) to detect Django as a top-level package.