Python requirements.txt 那个显示安装了哪个包?

Python requirements.txt that shows which package installed which?

我最近看到一个 python requirements.txt 文件,其中的条目如下所示:

hyper==15.2.1              # via twisted
iddna==1.5                 # via cryptography, requests

换句话说,它识别哪个包负责安装另一个作为依赖项。我想知道是否有我不知道的工具,或者作者是否手动添加了评论。或者是否有 pip freeze 的秘密选项?

这些添加到 requirements.txt 的注释不是从 pip freeze 选项生成的(pip freeze docs). They most likely come from pip-tools。从 README 中,pip-compile 命令将生成 requirements.txt 以及那些显示父依赖项的注释。希望这会有所帮助。