Some initial thoughts.
The PEP discusses “projects”, but doesn’t define what a project is. This is fairly reasonable, as everyone has an intuitive understanding of what a Python project is, but it does leave things open to confusion in a number of cases. Specifically, in the case of a monorepo, is the monorepo itself the “project”, or is each individual subproject its own “project”?
This ties in with my point above. I assume the idea is that I’m working with a tool on a “project”, and the point of this PEP is for the tool to be able to find my venv. But without some agreed way of knowing what the project I’m working on is, it’s not possible to do that discovery. And more importantly, it’s possible for the tool’s view to differ from my mental image - to give a simple example, many command line tools just work based on the CWD, so if I’m in a subdirectory of what I think of as the project, how do they do discovery? Given that the project might not have a venv, a simple search upwards doesn’t work - it could fail to spot that the current project has no venv because a containing directory for some reason does have a .venv file or directory in it.
Obviously, this issue can be fixed by stating that we only support certain layouts/workflows - but it’s a significant extension of the scope of the proposal if we’re now trying to define what’s “official”.
I agree. This PEP reads very much like a packaging interoperability spec. But I don’t think that core PEPs in general can make such statements about how people use the language - they certainly haven’t in the past (to my knowledge). Unlike Steve, I’m not sure I am happy with the core statement he summarised in his post - my feeling is that without the authority of a standard saying that users must work in a certain way, people will simply carry on the way they currently do, and tools won’t be able to assume things work any differently than they do now.
And the problem is that I don’t think the core team and the SC have the community support or authority to make statements about how people “must” use Python, or structure their workflow.
Maybe this is just because of the way the PEP is worded, but it feels like it’s trying to impose a “best practice” that would be easier for tools to support onto end users. If, instead, it presented the case more neutrally, maybe it would work better. How about the following structure:
- The PEP proposes an extension to how
venv stores virtual environments (a default name, and a “redirection” mechanism).
- It is assumed that other venv creation tools will implement the same mechanism, for compatibility as well as to provide the benefits of those mechanisms, provided below.
- Users will benefit from the change as follows (easier to find the venv because the default name is now standardised, a mechanism to put venvs elsewhere while still having a discoverable pointer to them).
- The proposal does not offer any new features for people or tools who use multiple venvs for a single project.
- The proposal is opt-in - users who don’t change how they invoke
venv will see no change.
- For users who do use the new features, tools that need to discover “the correct” virtual environment to use will be able to do so more easily. By following the existing convention of using the name
.venv, the discovery process will also work for many users who do not opt into the new mechanism.
- Tools which need to discover virtual environments may choose whether to continue supporting other conventions (assuming they do at the moment) - the PEP cannot influence that choice.
- Tools which expect
.venv to be a virtual environment may be confused by the new redirection mechanism. Any confusion should be minor, though, as finding a file rather than a directory should already be an error.
Put like that, it doesn’t feel like it’s making statements it can’t deliver on. But equally, the argument feels a lot less compelling - without an assumption that users will follow the recommended layout, tools can’t actually do anything differently from how they currently work. Which is the reality of what’s being proposed, but it’s harder to spot with the PEP as it’s currently written…
I should say, though - this PEP is more or less irrelevant to me as a user, because I already name my virtual environments .venv. So I don’t need the new features of venv, nor am I going to change my workflow in any way as a result of this. I suspect that’s true of a lot of people, but not everyone. As a result, getting feedback from those who are affected will be tricky.