Each package has a list of packages on which it depends.
Each of them defines a range of versions. and in order to make it easier, use semantic versioning.
The package Manager builds a dependency graph and selects the most recent fully matching set. Or write, why is this set to be impossible.
For example, you may not know if a compatible one or the other version
You put the requirements of those versions from which the package depends and on which it was tested.