Hi Pants experts, we are upgrading Python from 3.7...
# general
p
Hi Pants experts, we are upgrading Python from 3.7 to 3.10 for our repo managed by Pants. We want to support both versions in the process, so we made the requirements.txt support different version of a library like the following line shows:
Copy code
catboost==0.26.1; python_version == '3.7'
catboost==1.2; python_version == '3.10'
However, when running
./pants generate-lockfiles
we see errors such as: ERROR: Cannot install catboost==0.26.1 and catboost==1.2 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
The conflict is caused by:
The user requested catboost==0.26.1
The user requested catboost==1.2
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
My question is what is the best practice to let Pants resolve multiple versions of a dependency like this case? Thanks!
c
Hi 👋 Relevant docs to look at first are https://www.pantsbuild.org/docs/python-interpreter-compatibility#using-multiple-python-versions-in-the-same-project and https://www.pantsbuild.org/docs/targets#parametrizing-targets That will provide some insights how to tell Pants which versions of Python to target.
👍 1
h
Specifically, with your issue, you will need two different resolves.
A single lockfile can only lock a single version of any requirement
p
Thanks Benjy! We will do as suggested!