local_builder

UV-based local Lambda layer builder.

UvLambdaLayerLocalBuilder runs uv sync directly on the host machine to install dependencies into a Lambda-compatible layer structure.

See docs/source/99-Maintainer-Guide/03-Build-Lambda-Layer-using-UV-in-Container for the containerized variant’s architecture guide.

class aws_lbd_art_builder_uv.layer.local_builder.UvLambdaLayerLocalBuilder(verbose: bool = True, printer: ~typing.Callable[[str], None] = <built-in function print>, path_pyproject_toml: ~pathlib.Path = REQ, credentials: ~aws_lbd_art_builder_core.layer.foundation.Credentials | None = None, skip_prompt: bool = False, path_bin_uv: ~pathlib.Path | None = None)[source]

Build a Lambda layer using uv on the local machine.

Runs uv sync --frozen --no-dev --no-install-project --link-mode=copy on the host, then moves site-packages/ into artifacts/python/.

The local builder does not require py_ver_major / py_ver_minor because it always uses the host’s current Python — there is no way to target a different Python version without a container. The container builder requires them to select the correct AWS SAM base image.

Note

Local builds produce host-native binaries. For packages with C extensions, use UvLambdaLayerContainerBuilder instead.

step_2_1_setup_build_dir()[source]

Delete build/lambda/layer/ and recreate the directory structure.

step_2_2_prepare_uv_stuff()[source]

Copy pyproject.toml and uv.lock to build/lambda/layer/repo/.

step_3_execute_build()[source]

Credentials are set up here in Step 3 (right before uv sync) rather than in Step 2, because uv_login() sets process-level environment variables. Doing it in Step 2 would pollute the env during directory setup, and if Step 2 failed, the env vars would be left dangling. Keeping credential setup adjacent to the command that needs them minimizes the window of exposure.

(In the container builder, credentials are written to a JSON file in Step 2 because the container is a separate process — writing a file is a prepare action, not an execute action.)

step_3_1_uv_login()[source]

Set UV_INDEX_{NAME}_USERNAME/PASSWORD env vars for private repos.

step_3_2_run_uv_sync()[source]

Execute uv sync --frozen --no-dev --no-install-project --link-mode=copy.