Search code examples
pythonpiprequirements.txt

Python requirements.txt that shows which package installed which?


I recently saw a python requirements.txt file with entries that look like this:

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

In other words, it identifies which package was responsible for installing another as a dependency. I'm wondering if there's a tool out there that I don't know about or if the author has added the comments manually. Or is there a secret option for pip freeze?


Solution

  • These comments that were added to the requirements.txt are not generated from a pip freeze option (pip freeze docs). They most likely come from pip-tools. From the README, the pip-compile command will produce a requirements.txt with those comments showing the parent dependency. Hope this helps.