You should really try out the spack package manager, it will manage all these constraints between packages, variants, dependencies for you by feeding it a very simple description of what you want to install: https://github.com/spack/spack
https://archive.fosdem.org/2018/schedule/event/installing_so...