aws / aws/aws-lambda-builders

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

Ouverte
#892 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stage/needs-triage
Langage dominant
Python
Étoiles
381
Forks
162
Merge moyen
1 j 1 h
PR mergées (30 j)
2

Description

### 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:

```bash
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`

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la PR #887 et le workflow PythonUvBuilder, en particulier workflows/python_uv/packager.py, où le traceback montre la gestion de l’installation des dépendances. Reproduisez le workspace uv documenté avec un lib et un sam-app voisins, puis exécutez sam build --beta-features. C’est terminé lorsque l’application du workspace se construit correctement sans résoudre lib sous sam-app.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
build-system
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.