Closed albertferras-vrf closed 1 month ago
I want to work on this but I don't yet have a good solution for setuptools_scm
or other things that depend on the Git state.
I could special-case .git
in the array though it's not a great API.
@konstin @zanieb -- any ideas? If we're gonna support this, I think we need an answer for setuptools_scm
too since it's so popular.
Well... something like cache_key_paths = ["path.txt", { file = "other-path.txt }, { git = "." })
is an option? e.g. allow dictionaries so we can define types and default to paths if a simple value is provided? (git = "."
being a Git repository rooted in the project directory, we could also do like git = true
but I'm not sure it's better)
That seems reasonable to me.
How complicated does support for Git state need to be? Like... the commit hash changed? There are unstaged changes? The tree is dirty? Number of commits since a tag? etc.
I think "commit hash changed" is fine.
I guess setuptools-scm
will also reflect uncommitted changes, but that may not be necessary.
This exists as of v0.4.8. You can do things like:
[tool.uv]
cache-keys = [{ file = "pyproject.toml" }, { file = "requirements.txt" }, { git = true }]
Consider the following
pyproject.toml
file, which uses dynamic metadata to referencerequirements.in
files.When invoking the command
uv pip compile -o requirements.txt pyproject.toml
then setuptools is used to build the project, which is the tool that understands thedynamic
andtool.setuptools.dynamic
configuration. Once the build is finished, uv reads the package'srequires.txt
and generatesrequirements.txt
. The problem is that after (only) modifyingrequirements.in
, the commanduv pip compile
does not update therequirements.txt
file. This is because the contentpyproject.toml
did not change anduv
decide to not reinstall the package (call setuptools) again. The current workaround is to add--reinstall
or--reinstall-package=myproject
to the command or configuration and force setuptools to run.This was discussed in discord, and the user
@ThiefMaster
suggested that we could add a new configuration under[tool.uv]
which allows specifying which files have to be considered as part of 'pyproject.toml's cache key. One example would be:Worth mentioning also (not part of this ticket) that it would be good if
uv
supported popular dynamic implementations natively and not need to invoke setuptools for it.