cool-easter-32542
03/20/2023, 6:33 PMinstall_from_resolve feature in Pants 2.16, I ran into a situation where:
• pytest depends on attrs
• Resolve A pins attrs==21.4
• Resolve B pins attrs==22.2
When we set [pytest].install_from_resolve = "A" in pants.toml, the pytest Pex installed from the lockfile uses attrs==21.4. This works perfectly when testing code in resolve A, but we hit exceptions when running tests in resolve B because some code uses features that were only introduced in `v22`+ of attrs.
Though we specifically hit this problem with pytest, I can imagine the same thing happening for any Python tool with transitive dependencies that overlap those of user resolves.
Describe the solution you'd like
Instead of statically specifying one resolve in install_from_resolve, it would be nice if we could configure some marker value like:
[pytest]
install_from_resolve = "__magic_placeholder__"
When __magic_placeholder__ is set (or some other less-magic config is set), Pants would dynamically select the resolve/lockfile to install tools from, so that the tool resolve always matches the resolve of the covered code. i.e.:
• When running pytest over code in resolve A, install pytest out of the lockfile for resolve A
• When running pytest over code in resolve B, install pytest out of the lockfile for resolve B
• Etc. for other Python tools that install out of a lockfile
This would enable cases like the above, where it's possible to satisfy the requirement constraints of a tool (pytest) in any one user resolve, but not possible to satisfy the constraints of every user resolve simultaneously.
Describe alternatives you've considered
In our specific case we should be able to upgrade attrs in resolve A to get un-stuck. But I worry about repeatedly bumping into this problem as we bump dependency versions down the road.
pantsbuild/pants