Skip to content

Bug: PythonUvBuilder fails to build app with dependencies on editable installs in the workspace #892

Description

@noritada

Description:

An application created as a member of a uv workspace would fail to build if they depended on other workspace
members.

The following shows the problematic workspace structure.

workspace root
├── lib
│   ├── pyproject.toml
│   └── src
├── pyproject.toml
├── sam-app
│   ├── __init__.py
│   ├── app.py
│   ├── pyproject.toml
│   ├── samconfig.toml
│   └── template.yaml
└── uv.lock

Steps to reproduce:

uv init --bare
uv init --lib lib
sam init --name sam-app --runtime python3.14 --architecture arm64 \
    --dependency-manager pip --package-type Zip \
    --app-template hello-world
cd sam-app
uv init
uv add lib@../lib
# remove requirements.txt and edit the app
# edit template.yaml to configure `BuildMethod: python-uv` and `CodeUri: .`
sam build --beta-features

Observed result:

The following shows the problematic workspace structure and the error message.

2026-07-15 13:49:33,345 | Building from UV lock file
2026-07-15 13:49:33,346 | Executing UV command: /Users/me/.cargo/bin/uv export --format requirements.txt --no-emit-project --no-hashes --no-default-groups --output-file
/var/folders/8s/g1znx0c90vx3tz81t_rqqgyr0000gn/T/tmptz94ffbg/lock_requirements.txt --python 3.14
2026-07-15 13:49:33,499 | UV command return code: 0
2026-07-15 13:49:33,500 | UV stdout: # This file was autogenerated by uv via the following command:
#    uv export --format requirements.txt --no-emit-project --no-hashes --no-default-groups --output-file /var/folders/8s/g1znx0c90vx3tz81t_rqqgyr0000gn/T/tmptz94ffbg/lock_requirements.txt --python 3.14
-e ./lib
    # via sam-app

2026-07-15 13:49:33,500 | UV stderr: Using CPython 3.14.6 interpreter at: /opt/homebrew/opt/python@3.14/bin/python3.14
Resolved 3 packages in 8ms

2026-07-15 13:49:33,501 | Executing UV command: /Users/me/.cargo/bin/uv pip install -r /var/folders/8s/g1znx0c90vx3tz81t_rqqgyr0000gn/T/tmptz94ffbg/lock_requirements.txt --target
/Users/me/workspace/sam-app/.aws-sam/deps/351538c7-a05e-4aad-b5c5-928f241070b6 --cache-dir /var/folders/8s/g1znx0c90vx3tz81t_rqqgyr0000gn/T/tmptz94ffbg/uv-cache
--python-version 3.14 --python-platform aarch64-unknown-linux-gnu
2026-07-15 13:49:33,653 | UV command return code: 2
2026-07-15 13:49:33,655 | UV stdout:
2026-07-15 13:49:33,656 | UV stderr: Using CPython 3.13.0 interpreter at: /Users/me/workspace/.venv/bin/python3
error: Distribution not found at: file:///Users/me/workspace/sam-app/lib

2026-07-15 13:49:33,657 | Failed to build dependencies: UV package build failed: Failed to build from pyproject.toml: Lock file operation failed: Failed to install dependencies using uv: UV pip install
failed: Using CPython 3.13.0 interpreter at: /Users/me/workspace/.venv/bin/python3
error: Distribution not found at: file:///Users/me/workspace/sam-app/lib

2026-07-15 13:49:33,662 | PythonUvBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 348, in _build_from_lock_file
    self._uv_runner.install_requirements(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        requirements_path=temp_requirements,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<6 lines>...
        architecture=architecture,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 167, in install_requirements
    raise UvInstallationError(reason=f"UV pip install failed: {stderr}")
aws_lambda_builders.workflows.python_uv.exceptions.UvInstallationError: Failed to install dependencies using uv: UV pip install failed: Using CPython 3.13.0 interpreter at:
/Users/me/workspace/.venv/bin/python3
error: Distribution not found at: file:///Users/me/workspace/sam-app/lib


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 389, in _build_from_pyproject
    self._build_from_lock_file(lock_path, target_dir, scratch_dir, python_version, architecture, config)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 361, in _build_from_lock_file
    raise LockFileError(reason=str(e))
aws_lambda_builders.workflows.python_uv.exceptions.LockFileError: Lock file operation failed: Failed to install dependencies using uv: UV pip install failed: Using CPython 3.13.0 interpreter at:
/Users/me/workspace/.venv/bin/python3
error: Distribution not found at: file:///Users/me/workspace/sam-app/lib


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/actions.py", line 68, in execute
    package_builder.build_dependencies(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        artifacts_dir_path=target_artifact_dir,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        config=self.config,
        ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 229, in build_dependencies
    handler(manifest_path, artifacts_dir_path, scratch_dir_path, python_version, architecture, config)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 282, in _handle_pyproject_build
    self._build_from_pyproject(manifest_path, target_dir, scratch_dir, python_version, architecture, config)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/packager.py", line 392, in _build_from_pyproject
    raise UvBuildError(reason=f"Failed to build from pyproject.toml: {str(e)}")
aws_lambda_builders.workflows.python_uv.exceptions.UvBuildError: UV package build failed: Failed to build from pyproject.toml: Lock file operation failed: Failed to install dependencies using uv: UV pip
install failed: Using CPython 3.13.0 interpreter at: /Users/me/workspace/.venv/bin/python3
error: Distribution not found at: file:///Users/me/workspace/sam-app/lib


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflow.py", line 374, in run
    action.execute()
    ~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.162.1/libexec/lib/python3.14/site-packages/aws_lambda_builders/workflows/python_uv/actions.py", line 76, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: UV package build failed: Failed to build from pyproject.toml: Lock file operation failed: Failed to install dependencies using uv: UV pip install failed:
Using CPython 3.13.0 interpreter at: /Users/me/workspace/.venv/bin/python3
error: Distribution not found at: file:///Users/me/workspace/sam-app/lib

2026-07-15 13:49:33,711 | Exception raised during the execution

Build Failed

Even though lib and sam-app are in the same directory level in the workspace, the workflow attempts to install lib under sam-app.

Expected result:

Successful build is expected.

Notes

I've submitted PR #887 to fix for this issue.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac
  2. If using SAM CLI, sam --version: version 1.162.1
  3. AWS region: ap-northeast-1

Add --debug flag to any SAM CLI commands you are running

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions