Add src to default cache keys (#12062)

## Summary

This has come up a few times, so it seems worth addressing. If you
migrate from a flat layout to a `src` layout or vice versa, we now
invalidate the package metadata.

Closes https://github.com/astral-sh/uv/issues/12047
This commit is contained in:
Charlie Marsh
2025-03-17 14:56:10 -07:00
committed by GitHub
parent 040a5bbe5d
commit 7ea2f657fa
10 changed files with 396 additions and 76 deletions
+3 -2
View File
@@ -477,10 +477,11 @@ The keys to consider when caching builds for the project.
Cache keys enable you to specify the files or directories that should trigger a rebuild when
modified. By default, uv will rebuild a project whenever the `pyproject.toml`, `setup.py`,
or `setup.cfg` files in the project directory are modified, i.e.:
or `setup.cfg` files in the project directory are modified, or if a `src` directory is
added or removed, i.e.:
```toml
cache-keys = [{ file = "pyproject.toml" }, { file = "setup.py" }, { file = "setup.cfg" }]
cache-keys = [{ file = "pyproject.toml" }, { file = "setup.py" }, { file = "setup.cfg" }, { dir = "src" }]
```
As an example: if a project uses dynamic metadata to read its dependencies from a