PEP 832: virtual environment discovery

Yes, I am speaking for uv. I checked with Zanie and, from what we recall, our objection was to the “SHOULD” wording which made .venv something that tools were expected to provide. We have plans to allow users to opt out of maintaining a .venv altogether, as there are use cases where its presence causes problems for users. The current “MAY” wording makes it optional, which we’re happy with. We never had any fundamental objection to .venv being a file rather than a directory.

.python-envs is a shared list with no single owner. It may be trivial to add to it, but we can only reliably present users with a single uv-managed environment through this mechanism, the path to which may change depending on configuration. An environment we previously listed may still exist while no longer being kept in sync with the project, so we’d want to remove our old references to avoid confusion, without disturbing other tools’ entries. But not only is it more complex to mutate a shared file correctly, there are also a number of corner cases which mean we may have to guess which entries belong to us. That adds complexity and uncertainty that we would prefer to avoid.

The objections regarding multiple environments and other environment types, also listed in the rejection rationale, are addressed by .python-envs. But this does not appear incompatible with also allowing a .venv redirect file. Backwards compatibility remains a concern, but we would only want to create .venv as a file as a last resort when we cannot make a symlink or junction. If the PEP excludes that fallback, we cannot provide a conforming .venv in those cases. A tool that does not understand redirect files would not discover our environment through .venv in either case, but a redirect file at least tells the user where the environment is, so they can point the tool at it manually. A redirect file also makes a tool that does not understand it less likely to create a separate environment, avoiding what would probably be the most confusing outcome.