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

Use venv instead of virtualenv when available. #526

Closed
wants to merge 3 commits into from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 24, 2017

Attempt at fixing #523 as suggested by @pv.

return False
if LooseVersion(match.group(1)) < LooseVersion("3.3"):
self._virtualenv_argv = [
executable, "-mvirtualenv", "--no-site-packages"]
Copy link
Collaborator

@pv pv Jun 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should use current python, when using virtualenv?
venv is always bundled, but Virtualenv is not necessarily installed in the target Pythons...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point I was making in #523 (comment) is that venv is unable to create virtualenvs for pythons others than the current interpreter, so if we want the master python to use venv, then any other python in the test matrix either needs to be >=3.3 (i.e., have venv itself), or have virtualenv installed.

As I only work with Py3 that restriction seems acceptable to me, but I can also understand if you disagree, in which case I don't think such an approach can ever be made to work (unless builtin venv picks up the ability to create venvs for other pythons, but why whould they?). So, please let me know if I should try to fix the tests, or if you simply won't accept such a design (again, it's up to you, of course).

@pv
Copy link
Collaborator

pv commented Jun 25, 2017

Also, many tests seem to break.
I also suggest rebasing on master so that some misc CI issues fixed in #528 don't confound results.

@pv
Copy link
Collaborator

pv commented Jun 26, 2017 via email

@pv
Copy link
Collaborator

pv commented Jun 26, 2017 via email

@pv
Copy link
Collaborator

pv commented Jun 26, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 26, 2017

Ah, I see, your suggestion is to add a third environment type, "venv", in addition to the two existing ones ("conda" and "virtualenv"); it would only work if the entire matrix uses recent enough Pythons. Is my understanding correct? (If yes that looks reasonable to me.)

@pv
Copy link
Collaborator

pv commented Jun 26, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 26, 2017

Ah yes, thanks for the clarification. Will work on that.

@anntzer anntzer force-pushed the venv branch 2 times, most recently from ecce716 to ccfa886 Compare June 26, 2017 17:41
@pv pv added the needs-work The PR cannot be merged as is, further work required (explained in comments) label Jun 28, 2017
return False
if LooseVersion(match.group(1)) < LooseVersion("3.3"):
self._virtualenv_argv = [
sys.executable, "-mvirtualenv", "--no-site-packages"]
Copy link
Collaborator

@pv pv Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a classmethod, so the initialization cannot be done here.
The argument name self is misleading though, should be cls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if I rename "self" to "cls" everywhere in the class (which I'm happy to do) it should not change the semantics of the method (basically even now I'm just setting the attribute on the class rather than on the attribute, which should not matter).

I cannot reproduce the failure of test_run_build_failure or of test_run_spec locally (looks like pip is not getting installed for a reason I can't fathom), they pass for me locally. (test_web_regressions needs the selenium test driver which I don't have installed but given that it's essentially the same failure I don't think it's relevant).

@pv
Copy link
Collaborator

pv commented Jun 29, 2017 via email

@pv
Copy link
Collaborator

pv commented Jun 29, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 29, 2017

I apparently can't make this work and cannot even reproduce the test failures locally, so I am giving up on this attempt.
Feel free to close the PR.

@pv
Copy link
Collaborator

pv commented Jun 29, 2017 via email

@pv
Copy link
Collaborator

pv commented Jun 29, 2017 via email

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.553% when pulling 9881fe0 on anntzer:venv into 4a071f5 on spacetelescope:master.

@anntzer
Copy link
Contributor Author

anntzer commented Jun 29, 2017

Thanks for the careful suggestions.
But I still hit the same "pip not found" issue...

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 30, 2017

Wow, nice find.

It looks like this actually is a problem with ensurepip(?). venv installs pip via ensurepip while it is set up (https://github.com/python/cpython/blob/3.6/Lib/venv/__init__.py#L238), but the call to ensurepip (while nested-env is active) results in

Requirement already up-to-date: setuptools in ./outer-env/lib/python3.6/site-packages
Requirement already up-to-date: pip in ./outer-env/lib/python3.6/site-packages

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 30, 2017

No, pip is just not installed in the inner env (despite itself believing the contrary).

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 30, 2017

So it looks like that the outer-env pip leaks into the inner env.

(inner-env) $ python -minspect -d pip
Target: pip
Origin: /tmp/outer-env/lib/python3.6/site-packages/pip/__init__.py
Cached: /tmp/outer-env/lib/python3.6/site-packages/pip/__pycache__/__init__.cpython-36.pyc
Loader: <_frozen_importlib_external.SourceFileLoader object at 0x7f14adc063c8>
Submodule search path: ['/tmp/outer-env/lib/python3.6/site-packages/pip']

I guess that's good enough...

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 30, 2017

http://bugs.python.org/issue30811

I think accepting that virtualenv is a dependency even on recent Pythons (if not using conda) is a good enough compromise for me...

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@pv
Copy link
Collaborator

pv commented Jun 30, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Jun 30, 2017

That was a very sloppy report, I updated it.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.553% when pulling 180d0a9 on anntzer:venv into 4a071f5 on spacetelescope:master.

@pv pv added needs-work The PR cannot be merged as is, further work required (explained in comments) and removed needs-work The PR cannot be merged as is, further work required (explained in comments) labels Jan 13, 2018
@pv
Copy link
Collaborator

pv commented Sep 1, 2018

No activity: closing.

@pv pv closed this Sep 1, 2018
@anntzer anntzer deleted the venv branch September 1, 2018 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-work The PR cannot be merged as is, further work required (explained in comments)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants