serverless-python-requirements
serverless-python-requirements copied to clipboard
sls deploy with poetry fails when using local packages
Hello, I am using poetry for dependency management and am having an issue deploying when using local packages.
My pyproject.toml looks like this:
[tool.poetry.dependencies]
python = "^3.8"
sentry-sdk = "^0.19.5"
aws-psycopg2 = "^1.2.1"
SQLAlchemy = "^1.4.11"
GeoAlchemy2 = "^0.8.5"
boto3 = "^1.17.57"
aws = {path = "../../../shared/aws"}
db = {path = "../../../shared/db"}
requests = "^2.25.1"
Which produces a requirements.txt file like this:
aws @ /path/to/local/aws/pacakge/; python_version >= "3.8" and python_version < "4.0"
aws-psycopg2==1.2.1
boto3==1.17.57; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
botocore==1.20.57; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
certifi==2020.12.5; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
chardet==4.0.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
db @ /path/to/local/db/pacakge/; python_version >= "3.8" and python_version < "4.0"
geoalchemy2==0.8.5
greenlet==1.0.0; python_version >= "3" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and
python_version >= "3"
idna==2.10; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
jmespath==0.10.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
python-dateutil==2.8.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
requests==2.25.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
s3transfer==0.4.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
sentry-sdk==0.19.5
six==1.15.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
sqlalchemy==1.4.11; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
urllib3==1.26.3; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and
python_version < "4"
This then results in the error
STDERR: ERROR: Invalid requirement: 'aws @/path/to/local/aws/pacakge/'
Removing the aws @ before the path gets it working, but I'm currently doing this manually with each deployment and was wondering if there's a solution or I'm doing something wrong?
Apologies if this isn't in the desired format or has been brought up elsewhere, I looked in the open issues and didn't find anything there. Either way, any help is appreciate. Thanks.
Hi, I also had similar use case, I used serverless-requirements-plugin and Poetry as dependency management as well. I created sample monorepo with two Python lambdas using shared module: https://github.com/wermajew/serverless-lambda-python-monorepo. Maybe you can find it useful.