Commit e96d649
committed
fix(python-uv): take into account dependencies on other workspace members
This commit fixes an issue where 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 and the error
message.
```
workspace root
├── lib
│ ├── pyproject.toml
│ └── src
├── pyproject.toml
├── sam-app
│ ├── __init__.py
│ ├── app.py
│ ├── pyproject.toml
│ ├── samconfig.toml
│ └── template.yaml
└── uv.lock
```
```
Build Failed
Error: PythonUvBuilder:ResolveDependencies - 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: /path/to/workspace/.venv/bin/python3
error: Distribution not found at: file:///path/to/workspace/sam-app/lib
```
Even though `lib` and `sam-app` are in the same directory level in the
workspace, the workflow attempts to install `lib` under `sam-app`.
In the workflow, `uv export` outputs a list of dependency packages,
which is then passed to `uv pip install` for installation. When doing
so, [`uv export` outputs relative paths from the workspace root][1].
Therefore, `uv pip install` must be run from the workspace root, not
from the application directory.
Additionally, dependencies on other packages within the workspace are
exported as editable installations (e.g., `-e ./lib`) by default.
When this is passed to `uv pip install`, only the `.pth` (path
configuration) file for the package will be installed without the
package body. To prevent this, the `--no-editable` option needs to be
used.
[1]: astral-sh/uv#202381 parent 37cd1d1 commit e96d649
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
| |||
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
347 | 357 | | |
348 | 358 | | |
349 | 359 | | |
| |||
352 | 362 | | |
353 | 363 | | |
354 | 364 | | |
355 | | - | |
| 365 | + | |
356 | 366 | | |
357 | 367 | | |
358 | 368 | | |
| |||
0 commit comments