如何解决有没有办法在 Python requirements.txt 中生成库的描述
我正在尝试了解一个现有的大型 Python 项目,该项目在 requirements.txt 中列出了许多依赖项。我喜欢了解每个库的用途。
如果有一种方法可以从 pypi.org 或其他来源生成他们给出的简短描述,那将非常有帮助。
例如:
#requirement.txt
gluonts
aiohttp
预期结果:
gluonts | GluonTS is a Python toolkit for probabilistic time series modeling
aiohttp | Async http client/server framework
是否有工具(命令行/在线)可以提供有关 Python 依赖项的描述性见解?
解决方法
可以获取使用 pip 安装的软件包的描述。
pip show [options] <package>
例如
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: me@kennethreitz.org
License: Apache 2.0
Location: ..\programs\python\python38\lib\site-packages
Requires: urllib3,certifi,chardet,idna
Required-by:
您可以使用汇总字段作为说明。这当然取决于作者是否提供了足够清晰的描述。
您可以使用以下内容在 python 脚本中执行此操作
from pip._internal import main as pipmain
description = pipmain(['show','requests'])
,
如果您安装了这些软件包,则可以使用 pip show <package-name>
。例如:
$ pip show aiohttp
Name: aiohttp
Version: 3.7.3
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: /home/jack/repo/global-search-ingestion/global_search_lib/.venv/lib/python3.8/site-packages
Requires: typing-extensions,yarl,async-timeout,attrs,multidict
Required-by: faust,aiohttp-cors
要在您的 requirements.txt
上运行它,您可以使用 cut
和 xargs
pip show $(cat requirements.txt | cut -d "=" -f 1 | xargs)
这将列出您requirements.txt
中每个图书馆的元数据。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。