Commit ced895d
authored
fix(pypi): don't expose source-less uv.lock packages (#3938)
> [!NOTE]
> I created this PR with AI.
Fixes #3934.
## Problem
`pip.parse(uv_lock = ...)` exposes every `[[package]]` in the lock,
including uv workspace/root members with `source = { virtual = "." }`
(and editable installs). These resolve to no wheel/sdist (`srcs = []`)
but were still marked `is_exposed = True`, so the hub adds them to
`all_requirements` / `all_whl_requirements` and creates an alias to a
subpackage that doesn't exist. Anything enumerating the full set then
fails analysis, e.g. `modules_mapping(wheels = all_whl_requirements)`:
```
ERROR: no such package '@@rules_python++pip+pip//myproject': BUILD file not found ... and referenced by '//:modules_map'
```
## Fix
`_parse_uv_lock_json` in `python/private/pypi/parse_requirements.bzl`
set `is_exposed = True` unconditionally. This gates it on whether the
package actually resolved to any sources:
```starlark
is_exposed = bool(info["resolved_srcs"]),
```
The entry is still kept; it just isn't exposed when nothing resolved.
This mirrors the requirements path, which already gates `is_exposed`.
## Tests
As called out in the issue, this flips the expectations in two existing
tests, both of which assert on source-less packages:
- `_test_uv_lock_primary_source_includes_virtual` (the `virtual_pkg`
entry)
- `_test_uv_lock_requires_dist_extras` (the `root_pkg` entry)
Both now expect `is_exposed = False`.
A `news/3934.fixed.md` fragment is included.1 parent a57eff9 commit ced895d
3 files changed
Lines changed: 17 additions & 3 deletions
File tree
- news
- python/private/pypi
- tests/pypi/parse_requirements
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
296 | 303 | | |
297 | 304 | | |
298 | 305 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1193 | 1193 | | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | | - | |
| 1196 | + | |
1197 | 1197 | | |
1198 | 1198 | | |
1199 | 1199 | | |
| |||
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
1623 | | - | |
| 1623 | + | |
1624 | 1624 | | |
1625 | 1625 | | |
1626 | 1626 | | |
| |||
0 commit comments