I've installed a package named xformers, here's its dependency tree
D:\Projects\Learning>pipdeptree -p xformers
xformers==0.0.23.post1
├── numpy [required: Any, installed: 1.26.2]
└── torch [required: ==2.1.2, installed: 2.1.2+cu121]
├── filelock [required: Any, installed: 3.13.1]
├── fsspec [required: Any, installed: 2024.2.0]
├── Jinja2 [required: Any, installed: 3.1.3]
│ └── MarkupSafe [required: >=2.0, installed: 2.1.5]
├── networkx [required: Any, installed: 3.2.1]
├── sympy [required: Any, installed: 1.12]
│ └── mpmath [required: >=0.19, installed: 1.3.0]
└── typing_extensions [required: Any, installed: 4.10.0]
which shows its denpendency is torch==2.1.2
but the requirements.txt declares a lower version
torch >= 1.12
numpy
and setup.py just reads the requirements.txt (line 403), seems nothing else special.
then, how does it work?
the img below is a similar case with xformers==0.0.24 and torch==2.1.2, if it helps
When dealing with package dependencies in Python, especially when using pip and a requirements.txt file, the specified requirements serve as a baseline for compatibility. This means that the packages listed in requirements.txt are the minimum versions required for the software to run properly.
The process of determining which version of a dependency to install is based on resolving all the version constraints specified in the requirements.txt files of all installed packages. pip attempts to find a set of versions that satisfies all the constraints.