close

How do I list the files inside a python wheel?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How do I list the files inside a python wheel in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How do I list the files inside a python wheel?

  1. How do I list the files inside a python wheel?

    As others have pointed out in the answers, any .whl file can be extracted using unzip or by right clicking on the file and extracting using the Extract Here graphical interface in Ubuntu/Debian systems.

  2. list the files inside a python wheel

    As others have pointed out in the answers, any .whl file can be extracted using unzip or by right clicking on the file and extracting using the Extract Here graphical interface in Ubuntu/Debian systems.

Method 1

One could use Python’s own zipfile module and CLI to list the files in a wheel (or any other zip file):

python -m zipfile --list path/to/my-wheel-file.whl

Or to extract:

python -m zipfile --extract path/to/my-wheel-file.whl path/to/output/directory

Method 2

As others have pointed out in the answers, any .whl file can be extracted using unzip or by right clicking on the file and extracting using the Extract Here graphical interface in Ubuntu/Debian systems.

After extracting, one can inspect the source code of .py files and the contents of metadata files which will be located in library-name-with-version.dist-info directory. However, the source code of shared object (.so) files can not be inspected since that’s a binary file.


Another handy option would be to use the wheel-inspect package which is specifically built for this purpose. The description of the package is stated as:

wheel-inspect examines Python wheel files & *.dist-info directories and outputs various information about their contents as JSON-serializable objects.

A sample command is:

$ wheel2json some_lib_wheel_file.whl

That would spit out the contents in a json file. If this json file needs to be stored locally, then redirect the output to a json file.

$ wheel2json some_lib_wheel_file.whl > some_lib.json

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read