-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[PROOF OF CONCEPT] Use venv module to create the base Python where it's present #1343
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
Conversation
Bah. CI uses Python 3.7.2, where venv has a known issue that I haven't decided how to address yet. The other Windows failures may also be venv issues, I didn't do any manual tests with older versions yet as I didn't have them installed. I suspect those are because I'm still installing the modified site.py at this point. |
6a0230d
to
208745a
Compare
I'm not eager on this, switching to venv makes this tools behaviour Python dependent (venv in 3.5 may well behave differently than 3.7), where the whole point of it is to unify virtualenv behaviour independent of python used, so library users can really on a well-defined behaviour. As such I'm tempted to reject it. |
No problem, my main reason for experimenting was to see how practical it would be to use venv. I actually think that venv still has some odd edge cases that mean venv-using code will be annoyingly version-specific for a while yet. So I don't think it's something I'd want to take forward anyway. I may still tweak the PR a bit, just to see if I can work out why the tests are failing. I can't do that locally (the tests are taking 30 mins or so on my development PC :-() so I'm cheating by using CI. Hope that's OK. One thing I will say, though, is that I'd dispute the comment about version dependence. Yes, the internals (of virtualenv and of venv across versions) differ, but the user-facing behaviour (which is fundamentally "give me a Python interpreter that's isolated from my main one") should be the same. At the moment, there are quirks (for example, venv uses The problem at the moment is that venv won't stabilise fast enough if people don't use it. And many people use virtual environments through tools like pew or pipenv. Because of API differences, those tools have to choose one or the other, and they choose virtualenv because it's the only option. So we get in a vicious circle of no-one using venv, so venv still has rough edges, which mean people are unwilling to use it... My thought was that if virtualenv could use the venv "engine", users would get access to the more robust core-based engine, while still having the virtualenv UI and API. But that won't be possible unless this experiment had worked. So I'm now considering trying to write a "wrapper" library that will give a unified API over both venv and virtualenv. I don't know whether higher level tools would pick that up, but at least it will solve the integration problems in a single place. (And yes, the underlying differences will remain, but the wrapper can document and unify a common set of capabilities, and just not support the less universal ones). |
While you define the API as the higher level outcome of having a virtualenv, I define the API and goal of virtualenv of stable and unified behavior of the created virtualenvs, hence my stricter requirements. You can use the PR as cheap runner as much as you want 👍 |
I'm not disagreeing with this goal at all, but I'd be curious to know what you class as part of the "behaviour". As an example, do you consider having an identical Ideally, I'd like any virtualenv/venv wrapper I might write to preserve as many of the guarantees of virtualenv as I can - but without knowing for sure what those guarantees are, that's going to be hard. |
Not sure how useful it is, but I wrote a wrapper library on top of virtualenv and venv to abstract virtual environment creation across Python versions. It basically tries to use venv if possible[1], and fallback to virtualenv if that fails. [1]: The logic is to try importing |
If that site.py alters the way imports work, or how the virtualenv behaves then yes. It's part of the API. The expectation of where I draw the line is that |
This is not ready for merge - at this point it is simply a proof of concept.
Looking at the stdlib venv module and the virtualenv codebase, it seems that the process of creating the base virtual environment (before we add in all of the scripts and install pip, etc) could be handled using the programming API for venv. There are some differences in API that need to be ironed out, but if it works, this would make virtualenv compatible with venv (in the sense of using the virtual environment support built into core Python).
This isn't any sort of attempt to make the two tools compatible at the UI level, it's purely about using the core mechanism when it's available.
At the moment, all I'm doing here is using the virtualenv CI infrastructure to ensure the change works. It needs a lot more manual testing and work before it's going to be ready to propose for actual merging.