Search code examples
pythonpypi

Is there a way to generate description of libraries in Python requirement.txt


I am trying to understand an existing big python project which has lot of dependencies listed in requirement.txt. I like to understand what each libraries is meant for.

If there is a way to generate a short description given by them from pypi.org or other sources, that would greatly help.

For example:

#requirement.txt
gluonts
aiohttp

Expected outcome:

gluonts | GluonTS is a Python toolkit for probabilistic time series modeling
aiohttp | Async http client/server framework

Is there a tool (command line / online) that can provide descriptive insights on python dependencies ?


Solution

  • It is possible to get a description of packages installed using pip.

    pip show [options] <package>
    

    For example

    pip show requests
    Name: requests
    Version: 2.25.1
    Summary: Python HTTP for Humans.
    Home-page: https://requests.readthedocs.io
    Author: Kenneth Reitz
    Author-email: [email protected]
    License: Apache 2.0
    Location: ..\programs\python\python38\lib\site-packages
    Requires: urllib3, certifi, chardet, idna
    Required-by:
    

    You can use the summary field as a description. This of course relies upon the author having provided a sufficiently clear description.

    You can do this inside a python script using the following

    from pip._internal import main as pipmain
    description = pipmain(['show','requests'])