Description
Expected Behaviour
When defining a requirements.txt
file with dependencies, it should be possible to define it like this:
aws-lambda-powertools[all]~=2.22.0
pydantic[email]~=2.1.1
Running pip install -r requirements.txt
should install both aws-lambda-powertools
and pydantic
packages. AWS Lambda Powertools is compatible with Pydantic V2 thanks to #2733.
Current Behaviour
Running pip install -r requirements.txt
raises the following error:
ERROR: Cannot install aws-lambda-powertools[all]==2.22.0 and pydantic[email]==2.1.1 because these package versions have conflicting dependencies.
The conflict is caused by:
- aws-lambda-powertools[all] 2.22.0 depends on pydantic<2.0.0 and >=1.8.2; extra == "parser" or extra == "all"
- pydantic[email] 2.1.1 depends on pydantic 2.1.1 (Installed)
Code snippet
aws-lambda-powertools[all]~=2.22.0
pydantic[email]~=2.1.1
pip install -r requirements.txt
Possible Solution
I was surprised when finding this error because, based on #2672 and #2733, it seems like AWS Lambda Powertools was already compatible with Pydantic V2.
However, when looking at the pyproject.toml
file I found out about the dependency being still in V1:
[tool.poetry.dependencies]
...
pydantic = { version = "^1.8.2", optional = true }
Shouldn't this be set to be either ^1.8.2
or ^2.0.3
(based on Pydantic V2 usage docs)?
So, a possible solution could be:
[tool.poetry.dependencies]
...
pydantic = { version = ">=1.8.2, !=2.0.0, !=2.0.1, !=2.0.2, <3.0.0", optional = true }
Ideally, it would be nice to have something like ^1.8.2 || ^2.0.3
, but not sure if that's allowed in Poetry.
Steps to Reproduce
- Create a
requirements.txt
file. - Include both AWS Lambda Powertools and Pydantic V2 as direct dependencies.
- Try to install dependencies through
pip install -r requirements.txt
.
Powertools for AWS Lambda (Python) version
2.22.0
AWS Lambda function runtime
3.11
Packaging format used
Lambda Layers, PyPi
Debugging logs
No response
Metadata
Metadata
Assignees
Type
Projects
Status