When you tell pip to install multiple packages simultaneously, it looks up all child dependencies and installs the most recent version that is allowed by all parent package restrictions.
For example, if packageA requires child>=0.9 and packageB requires child<=1.1, then pip will install child==1.1.
I'm trying to write a script to scan a requirements.txt
and pin all unlisted child package versions.
One way to do this would be to simply install everything from a requirements.txt
file via pip install -r requirements.txt
, then parse the output of pip freeze
, and strip out all the packages from my requirements.txt
file. Everything left should be child packages and the highest version number that pip calculated.
However, this requires creating a Python virtual environment and installing all packages, which can take a bit a time. Is there any option in pip to do the version calculation without actually installing the packages? If not, is there pip-like tool that provides this?