Skip to content

Conversation

@rivhar
Copy link

@rivhar rivhar commented Jan 5, 2026

Description

This PR adds support for the uv package manager for Python Lambda functions. It introduces a new build system autodetection logic in package.py and provides updated build environments via Docker.

Key changes include:
Autodetection: Added logic to recognize uv as a build system when a uv.lock or specific pyproject.toml configuration is present.
Docker Support: Updated the Lambda build Dockerfile to include uv (pinned to version 0.9.21) to ensure stable, containerized builds.
Layer Compatibility: Integrated uv export with the existing prefix_in_zip logic to ensure dependencies are correctly placed in the python/ folder for Lambda Layers.
Examples: Created new fixtures and examples in examples/fixtures/python-app-uv and examples/build-package to demonstrate local and Docker-based UV builds.

Motivation and Context

uv is an extremely fast Python package manager that is gaining significant traction in the community. Adding native support allows users to benefit from faster build times and reliable dependency resolution (via uv.lock) without leaving the terraform-aws-lambda ecosystem.
Closes #673

Breaking Changes

None. This change is purely additive. Existing Poetry and Pip-based workflows remain untouched. The autodetection logic is designed to fall back to existing methods if uv specific files are not found.

How Has This Been Tested?

[x] I have updated at least one of the examples/* to demonstrate and validate my change(s)
[x] I have tested and validated these changes using one or more of the provided examples/* projects
[x] I have executed pre-commit run -a on my pull request

Detailed testing performed:

Unit Testing: Ran pytest tests/test_package_toml.py. All tests for the new UV build system detection passed.
Integration (Local): Deployed module.package_dir_uv_no_docker using a local uv binary; verified the resulting ZIP contained all dependencies.
Integration (Docker): Deployed module.package_dir_uv using the updated Dockerfile; verified uv export and pip install executed correctly inside the container.
Layer Verification: Inspected the ZIP artifact for module.lambda_layer_uv using zipinfo. Verified all dependencies are correctly prefixed with python/ for Lambda runtime compatibility.

@rivhar rivhar force-pushed the feat/add-uv-support branch from f44447c to 6a499cf Compare January 5, 2026 19:53
@rivhar rivhar changed the title feat: add uv support for python packaging feat: Add uv support for python packaging Jan 5, 2026
@rivhar rivhar force-pushed the feat/add-uv-support branch from fdef682 to 88d8221 Compare January 9, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat Request: Add support for uv based Python builds

1 participant