Closed soerenwolfers closed 2 months ago
It looks like this is because you are passing a list of pip._vendor.pkg_resources.DistInfoDistribution
when we now expect importlib.metadata.Distribution
.
pip._vendor.pkg_resources.DistInfoDistribution
is a sublcass of pip._vendor.pkg_resources.Distribution
, and when we try to perform obj.metadata['Name']
, the metadata
attribute fails to be looked up, and since the class implements __getattr__()
, it uses it (see implementation here). It delegates attribute lookup to self._provider
, but since metadata
doesn't exist here either we will see the failure.
Looking at the stack trace further, it looks like you are using our API. Sadly, this is internal API and therefore may change in future releases.
I don't recommend you continue using the API, but if you really need it I think I see three options:
importlib.metadata.Distribution
objectspip._vendor.pkg_resources.DistInfoDistribution
object in another class that inherits from importlib.metadata.Distribution
and implements its abstract methods (see here)Thanks for the quick response. Will probably change tooling, I really do need a stable API, not a command line tool
What pipdeptree version are you using?
2.17.0
Are you running pipdeptree in a virtual environment?
Describe the problem
Getting
python3.10 importlib_metadata==7.1.0 pipdeptree=2.17.0
https://github.com/tox-dev/pipdeptree/blame/main/src/pipdeptree/_models/package.py#L103