Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List dependencies of Python wheel file

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

How can I list the dependencies this wheel has?

like image 793
guettli Avatar asked May 04 '18 08:05

guettli


People also ask

How do I check wheel dependencies in Python?

Pip Check Command – Check Python Dependencies After Installation. Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project. For example: $ pip check No broken requirements found.

Do Python wheels contain dependencies?

Python package installed with pip , e.g. WheelPython dependencies can be specified as dependencies in your packaging, and automatically installed by pip . You can include third party C libraries in wheels, but for sufficiently complex dependencies that won't work.

How do you get dependencies in Python?

Download Dependencies OnlyUse the pipdeptree utility to gather a list of all dependencies, create a requirements. txt file listing all the dependencies, and then download them with the pip download command. Get the list of dependencies for a package from the setup.py file.

How do I get the dependencies tree of Python package?

One easy way of doing so is to use the pipdeptree utility. The pipdeptree works on the command line and shows the installed python packages in the form of a dependency tree.


1 Answers

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'"] 
like image 138
samu Avatar answered Oct 14 '22 16:10

samu