Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable reading uv.toml from venv #9935

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JonneDatanen
Copy link
Contributor

@JonneDatanen JonneDatanen commented Dec 16, 2024

Resolves: #8107

Summary

Sometimes I would like to have per-venv uv.toml so that there could be e.g. multiple venv's with different constraints where different projects are run/tested. System/user wide configuration forbids doing many venv's and project settings doesn't allow running with different set of constraints.

Having configuration files within the venv is also a feature that pip supports: https://pip.pypa.io/en/stable/topics/configuration/#location

Test Plan

Manually tested by creating venv and adding uv.toml there -> constraints were resolved correctly.

@zanieb zanieb added the needs-decision Undecided if this should be done label Dec 17, 2024
@zanieb
Copy link
Member

zanieb commented Dec 17, 2024

I think we're pretty hesitant to do this. When we recreate a virtual environment, we delete the entire directory. It doesn't seem like a good place for additional state, like settings.

What does

project settings doesn't allow running with different set of constraints

mean?

@JonneDatanen
Copy link
Contributor Author

JonneDatanen commented Dec 17, 2024

What does

project settings doesn't allow running with different set of constraints

mean?

We have some "fixed" python production environments. E.g.:

  • prod-env0 -> python==3.8, numpy==1.17.0, pandas==0.24.0, ...
  • prod-env1 -> python==3.10, numpy==1.24.4, pandas==1.4.4, ...
  • prod-env2 -> python==3.12, numpy==2.13.0, pandas==2.2.2, ...
  • etc...

And then we have e.g. python package foo that we ci-test and guarantee to run smoothly in e.g. env1 and env2.

That means that we want to give some set of hard constraints while installing foo, but:

  • They cannot be in pyproject.toml as the constraints are different based on the env we are testing/running the package
  • They cannot be in ~/.config/uv.toml as the same user might want to test in different venv's

So for our use case it is better to have venv-specific configs, that can be generated (with script, prod-env init 0) after I create new venv. Currently we have that kind of script for pip, but I would definitely like to switch to uv pip if pip-like venv specific uv.toml would be possible.

Of course this doesn't maybe fit nicely to uv sync/uv lock way of working, but having this in uv pip would be nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Undecided if this should be done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv to detect uv.toml in active venv
2 participants