Menu

uv for AWS Lambda: Packaging Python Dependencies
πŸ“°

uv for AWS Lambda: Packaging Python Dependencies

DEV Community: pythonΒ·Sascha Mirow-StanitzokΒ·4 days ago
#PpXBuWhM
#devtopython#devto#dev#python#layer
Reading 0:00
15s threshold

Using uv for AWS Lambda lets you build Python dependencies that behave in the cloud exactly as they did in your tests: reproducible from a lockfile, matched to the Lambda architecture and done in seconds rather than minutes. If you have ever deployed a function that was green locally and then crashed in AWS with a cryptic ImportError , you know why this matters.

I care about this topic because Python packaging for Lambda used to be the least loved part of an otherwise pleasant serverless project. Plugins, Docker containers that crawl on a Mac, and in the end still a wrong binary inside the zip. uv has made this a lot easier. In this article you will build, step by step, a small Python function with a dependency that ships native code, and deploy it with the Serverless Framework.

In short

uv turns uv.lock into an exact list of your runtime dependencies and uses --python-platform to install them as Linux wheels for your function's architecture, even when you work on a Mac or a Windows machine.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.