feat: implement uv project support as a layout
This is an alternative implementation of #1250 that is approached differently from #1329 which is venv-focused. This PR specifically uses uv's project implementation, not a virtualenv.
I elected in the initial pass at it to assume:
- if you don't already have a project, this should error out
- you want the project's installed binaries on your PATH
Note
I'm not going to adopt any more suggestions til I hear from the direnv maintainers whether this is even a reasonable approach. I legit don't know who I'm supposed to convince here or who has merge permissions, so I'd like to wait on that before adding more churn.
Would you consider making virtualenv activation optional? Currently most users probably prefer activation, so that should probably be the default.
100% willing to, but I'll admit I do not see any other patterns in the stdlib for options like that. Do you have a recommended pattern? I'm modeling this off of the layout python which effectively activates the virtualenv, so it seemed reasonable to do so here.
I could also just PATH_add "$(pwd)/.venv/bin" -- ; that would be more or less exactly what layout python does; I'm neutral on that.
Or we could stick with the current activation. I don't see a lot of value in doing a half-layout here.
I'm refering to point 5 here, i.e. activation isn't necessary if you use uv run and might (and that's a big might) be even less so in the future.
Or we could stick with the current activation. I don't see a lot of value in doing a half-layout here.
That's probably also fine. One could just use uv sync directly in the .envrc and be done with it. Actually that might not even be necessary, since uv run updates the environment before running the command.
Activation isn't necessary if you uv run but it also doesn't affect it or harm it, but activation does make the direnv integrations in things like emacs et al work seamlessly, so on balance I think I'd prefer to keep it in.
How about a comparison to uvp in https://github.com/direnv/direnv/pull/1329 that uses uv's project implementation ?