This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pyvenv says nothing on success
Type: Stage:
Components: Demos and Tools, Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, loewis, orsenthil, pitrou, python-dev, vinay.sajip
Priority: normal Keywords:

Created on 2012-07-07 15:55 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (13)
msg164891 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-07 15:55
$ pyvenv-3.3 env
$

It could tell me that I need to go into the directory and type "source bin/activate" (this is probably platform-dependent :-)).
msg164894 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-07-07 16:04
It should produce any output. Command line utilities typically don't provide a success report. Would you want "mkdir env" to say "created env directory; you can now cd into it", or "cat /etc/passwd" append "successfully displayed text file"???

There are exceptions, of course, such as make(1). They may be reasonable in cases where the user might not be certain what constitutes a successful operation. In this case, it's fairly clear what you wanted to happen. In case you don't know in detail what is in the venv, you can look for yourself.

Whether "source activate" is good advise or not, I'm not so sure - I'd typically run  env/bin/python instead.
msg164898 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-07 16:08
> Command line utilities typically don't provide a success report.

It depends which ones. Even Mercurial doesn't always abide by that rule (e.g. "hg clone" will tell you that it updates to the default branch).

> Whether "source activate" is good advise or not, I'm not so sure - I'd 
> typically run  env/bin/python instead.

That's good if you only want to use the interpreter directly, but not if you want to call any scripts.

Also, the reason I think "source activate" is good advice is that it's easy to type instead "./bin/activate" which silently succeeds (but is actually a no-op, from the caller's point of view).
msg164929 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-07-07 20:04
The reason it says nothing on success is that it follows the general philosophy of programs on Unix. Of course, there are exceptions, but it's not obvious that pyvenv should say anything, and what it should presume is the user's next likely step. As well as running the venv's Python, any script in the venv should be immediately invokable (and call up the venv's interpreter). At the moment, that's just pydoc - but that might change over time (I originally had pysetup in there, before packaging got pulled).

AFAIK the activate script shouldn't have the executable bit set, so it shouldn't show up in e.g. autocomplete results. Note also that the activate script is bash-specific, so it may not be wise to mention it in cases where the user's shell may not be bash or a compatible shell.

It's assumed that third party tools will build on top of the existing venv support - for example, in the absence of packaging, venvs will need distribute/pip in order for users to be able to install stuff into them. These will likely provide the visual feedback required (e.g. before merging into CPython, the pythonv version of pyvenv installed Distribute in the venv, which showed that something was happening).
msg164931 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-07 20:14
> The reason it says nothing on success is that it follows the general
> philosophy of programs on Unix. Of course, there are exceptions, but
> it's not obvious that pyvenv should say anything, and what it should
> presume is the user's next likely step.

Well, having to run "source bin/activate" is not obvious (unless you've
already used virtualenv), so it's quite helpful to mention it. It's not
about being the next step, it's simply about informating the user.
Creating a venv is useless if you don't ever activate it, right.

If it's not in the pyvenv output, then perhaps it should be in the
"pyvenv --help" output. This way, users have an easy way to remind
themselves how to do. Having to context-switch to a browser and find the
module docs is too tedious.

> AFAIK the activate script shouldn't have the executable bit set, so it
> shouldn't show up in e.g. autocomplete results.

It does:

$ pyvenv-3.3 env
$ ls -la env/bin/activate 
-rwxr-xr-x 1 antoine antoine 2133 juil.  7 22:06 env/bin/activate*

> Note also that the activate script is bash-specific, so it may not be
> wise to mention it in cases where the user's shell may not be bash or
> a compatible shell.

Then the help output can be bash-specific too :)

> These will likely provide the visual feedback required (e.g. before
> merging into CPython, the pythonv version of pyvenv installed
> Distribute in the venv, which showed that something was happening).

Uh, I disagree with the idea that you should install something else to
make pyvenv useful. We should provide useful functionality out of the
box. Especially when doing so isn't particularly difficult or brittle.
msg164932 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-07-07 20:24
> Well, having to run "source bin/activate" is not obvious (unless you've
> already used virtualenv)

Using venv is not obvious in the first place. so presumably, the user has
read some documentation telling him what it is and how it's used. Presumably,
that documentation then mentions the activate script (with pros and cons).

I remain -1 on printing anything by default.
msg164934 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-07 20:29
> > Well, having to run "source bin/activate" is not obvious (unless you've
> > already used virtualenv)
> 
> Using venv is not obvious in the first place.

Well, why couldn't it *become* obvious. It's not supposed to be a
complicated piece of software. It does one single thing and it has only
a handful of options (one of which is a no-op :-)).
msg164943 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-07-07 21:41
>> Using venv is not obvious in the first place.
>
> Well, why couldn't it *become* obvious.

Because the notion of a "virtual environment" is inherently
non-obvious. Is it like a virtual machine (and if so, like
VMWare or like Java, both with virtual machines - doesn't
Python have a virtual machine already)? Is it like a virtual
host in Apache? I asked people, and even after explaining what
it is, it was not clear to them what it is good for. You really
need to have the problem that it solves, or else you can't
comprehend what it does. Please trust me on that.
msg164952 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-07-07 23:17
> It does one single thing and it has only a handful of options
> (one of which is a no-op :-)).

Perhaps it's a no-op only on your preferred operating system - that doesn't mean it's a no-op for everyone :-)

I don't mind clarifying/expanding the help output, but I also feel there's no need to print anything by default when a venv is created.
msg165025 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-08 16:51
New changeset 9c345b4bd97e by Vinay Sajip in branch 'default':
Closes #15281, #15283: Don't make venv scripts executable, but copy source mode instead, and provide better help for pyvenv.
http://hg.python.org/cpython/rev/9c345b4bd97e
msg165031 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-07-08 18:40
> Creating a venv is useless if you don't ever activate it, right.
This is a common misconception.  Shell activation is only about putting the venv’s bin directory on the beginning of the PATH.  It’s a purely optional convenience.  Using a virtualenv can be done fully with explicit paths like Martin mentioned.
msg165034 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2012-07-08 20:52
I think, the ``source bin/activate`` should be mentioned in the Docs
at least. It should not require that a person carries this knowledge
from somewhere else. At the moment, I do not see mention of it in the
docs either -

http://docs.python.org/dev/library/venv.html
msg165071 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-09 08:25
New changeset baf5ed391a7f by Vinay Sajip in branch 'default':
Issue #15283: Updated pyvenv documentation to expand on activation.
http://hg.python.org/cpython/rev/baf5ed391a7f
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59488
2012-07-09 08:25:58python-devsetmessages: + msg165071
2012-07-08 20:52:14orsenthilsetnosy: + orsenthil
messages: + msg165034
2012-07-08 18:40:51eric.araujosetnosy: + eric.araujo
messages: + msg165031
2012-07-08 16:52:19vinay.sajipsetstatus: open -> closed
resolution: fixed
2012-07-08 16:51:05python-devsetnosy: + python-dev
messages: + msg165025
2012-07-07 23:17:50vinay.sajipsetmessages: + msg164952
2012-07-07 21:41:07loewissetmessages: + msg164943
2012-07-07 20:29:57pitrousetmessages: + msg164934
2012-07-07 20:24:00loewissetmessages: + msg164932
2012-07-07 20:14:36pitrousetmessages: + msg164931
2012-07-07 20:04:40vinay.sajipsetmessages: + msg164929
2012-07-07 16:08:29pitrousetmessages: + msg164898
2012-07-07 16:04:21loewissetnosy: + loewis
messages: + msg164894
2012-07-07 15:55:17pitroucreate