You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existence of a directory named .venv in an ancestor of the current directory seems to influence the behavior of uv init. In particular, it will look for the version of Python installed in it and put it into requires-python. This is problematic because:
By definition, uv init is going to create a new project which will define, in its own pyproject.toml, what it wants from the environment it’s going to run in. That some other thing that resides in a parent directory happened to configure its own venv in a particular way is irrelevant.
The directory named .venv isn’t necessarily a fully-functional virtual environment. If it was created within a Docker container and became visible to the host because of a volume mount, the symlinks inside will likely appear to be broken and uv init will fail entirely. Or maybe the user has a ~/.venv directory that’s just a container for various venvs and is not a venv itself.
There doesn’t seem to be a switch to disable this discovery.
It’s undocumented.
Given that uv can install Python like any other package, is there any reason not to follow the same process as with any other package and put the latest version into requires-python, ignoring all .venv directories, at least for --app? (--libs in general require permissive versioning so there should be some heuristic about what to put into requires-python, but that’s a different question.)
The text was updated successfully, but these errors were encountered:
…n version for new projects (#9075)
`uv init` shouldn't have been using `EnvironmentPreference::Any` for
discovery of a Python interpreter, it seems like an oversight that it
was reading from virtual environments. I changed it to
`EnvironmentPreference::OnlySystem` so we'll use the first Python on the
`PATH` instead. However, I think we actually do want to respect a
virtual environment's Python version if it's in the target project
directory already, so I've implemented that as well.
Closes#9072Closes#8092
The existence of a directory named
.venv
in an ancestor of the current directory seems to influence the behavior ofuv init
. In particular, it will look for the version of Python installed in it and put it into requires-python. This is problematic because:.venv
isn’t necessarily a fully-functional virtual environment. If it was created within a Docker container and became visible to the host because of a volume mount, the symlinks inside will likely appear to be broken anduv init
will fail entirely. Or maybe the user has a ~/.venv directory that’s just a container for various venvs and is not a venv itself.Given that uv can install Python like any other package, is there any reason not to follow the same process as with any other package and put the latest version into requires-python, ignoring all .venv directories, at least for
--app
? (--lib
s in general require permissive versioning so there should be some heuristic about what to put into requires-python, but that’s a different question.)The text was updated successfully, but these errors were encountered: