3

I am trying to package a local python package¹ and use it within an AWS lambda deployed via the Serverless framework. I already use serverless-python-requirements plugin to add pip dependencies to deployed package.

How can I proceed ?

Shall I create a package and zip it? Or generate a whl file and use pip? And then, how to deploy it?


¹: I cannot just add it to "normal codebase" as I want to share it with other bricks (Glue jobs for example)

1 Answer 1

2

Here's the solution:

1.

Build a .whl file corresponding to package using

python setup.py bdist_wheel

within a parent directory.

2.

Add the relative path to this .whl file to used pip requirement file (requirements.txt for instance) :

req0==1.0.9
req1==5.5.0
../<relative path to local package>/dist/<package name>-<version>-<details>.whl # generated .whl file's name
3.

serverless-python-requirements will automagically pack this dependency within the deployed archive when doing sls deploy. How cool is that, huh!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.