https://pantsbuild.org/ logo
#general
Title
# general
p

plain-carpet-73994

05/03/2021, 6:03 PM
I've got a constraints file generated by
pip-compile
that includes an extra like:
Copy code
google-api-core[grpc]==1.26.3
but Pants doesn't like that:
Copy code
DEPRECATION: Constraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms. A possible replacement is replacing the constraint with a requirement.. You can find discussion regarding this at <https://github.com/pypa/pip/issues/8210>.
ERROR: Constraints cannot have extras
Aren't extras required for proper support in some cases? What's the correct way to deal with an optional extra that is required by the code if I want to be freezing dependencies?
h

hundreds-father-404

05/03/2021, 6:44 PM
Hey Oliver! It looks like that error message is coming from pip, rather than Pants. I believe if you keep the extra in the requirements.txt, the extra will still end up getting resolved. So for now, try removing it from the constraints. Is that working or not doing what you'd want? -- Btw, my main project this month is revisiting Python dependency management to improve some things like: 1) add dedicated lock files per tool 2) support multiple lockfiles possible for your own code 3) Pants can generate lockfiles for you It's very likely we will stop using Pip's constraints file feature and instead use a different approach that sidesteps these limitations of constraints files, which will avoid this problem you're having
p

plain-carpet-73994

05/03/2021, 6:45 PM
cool. Thanks!
❤️ 1
h

happy-kitchen-89482

05/03/2021, 9:18 PM
Yeah, I think the purpose of the constraints file is just to lock versions, but the extras still have to be in requirements.txt. This is a pip-level thing.
8 Views