List dependencies of Python wheel file

guettli picture guettli · May 4, 2018 · Viewed 13.7k times · Source

I have Python wheel file: psutil-5.4.5-cp26-none-linux_x86_64.whl

How can I list the dependencies this wheel has?

Answer

samu picture samu · May 7, 2018

As previously mentioned, .whl files are just ZIP archives. You can just open them and poke around in the METADATA file.

There is a tool, however, that can make this manual process a bit easier. You can use pkginfo, which can be installed with pip.

CLI usage:

$ pip install pkginfo
$ pkginfo -f requires_dist psutil-5.4.5-cp27-none-win32.whl
requires_dist: ["enum34; extra == 'enum'"]

API usage:

>>> import pkginfo
>>> wheel_fname = "psutil-5.4.5-cp27-none-win32.whl"
>>> metadata = pkginfo.get_metadata(wheel_fname)
>>> metadata.requires_dist
[u"enum34 ; extra == 'enum'"]