Dear pythonistas, I was wondering if we could add a clarification to PEP 394? I'm trying to get some visibility on this. There's a bullet in the PEP that states: *For scripts that are only expected to be run in an activated virtual environment, shebang lines can be written as #!/usr/bin/env python, as this instructs the script to respect the active virtual environment.* Could we clarify the following? - env is a system binary in /usr/bin available in most Linux distros that searches $PATH for strings containing the provided argument and returns the first instance it finds. In the above syntax, env will search for the first instance of python in $PATH and return it. - The shebang #! /usr/bin/env python works equally well in Linux when a script is to be run from within an activated virtual environment or when a default python installation is to be used and it is uncertain whether the python interpreter exists in /bin , /usr/bin , /usr/local/bin, or another custom path. - Since python may be an alias for python2 or python3 (typically, it is an alias for python2), the developer may choose to be specific and use the shebang #!/usr/bin/env python3 where desired. The Windows py launcher also accepts this shebang and searches the application directory, current directory, system directories, and PATH for “python.exe”. However, note that using python3 instead of python will not work as expected because it will instead use the preferred version of python 3.x that's installed and not look through directories. Although PEP 394 is geared towards Linux users, those unfamiliar with Linux don't know what env is or what it does. I've posted this issue here <https://discuss.python.org/t/pep-394-clarify-bullet-for-usr-bin-env-python/7953> and give some more information. Guido said I should post this on python-dev, but I'm still waiting for access. Does anyone have any thoughts? Thank you, Adam Hendry
Moving to Python Dev, reply-to set. Please reply to Python-Dev only. Full message appended at end for context. Adam Hendry writes:
Although PEP 394 is geared towards Linux users, those unfamiliar with Linux don't know what env is or what it does.
env(1) is not Linux-specific. It a POSIX 1 standard utility (presumably later versions of POSIX, as well). If env is not available on other OSes supported by Python, we should just say so. There's no need to add a ton of explanation of what it does, just refer to the man page.
Guido said I should post this on python-dev, but I'm still waiting for access.
It's not clear whether you have actually posted. FYI, once you have subscribed to the list, you can post. As a new member, for spam control your early messages are moderated, but that only imposes a few hours delay. Once it's confirmed you're a real Python developer (often at the first message), the moderation hold is removed and you can post freely, and will be distributed in a timely fashion. Regards, Steve Full post follows.
----------------------------------------------------------------------
Adam Hendry writes:
Dear pythonistas,
I was wondering if we could add a clarification to PEP 394? I'm trying to get some visibility on this.
There's a bullet in the PEP that states:
*For scripts that are only expected to be run in an activated virtual environment, shebang lines can be written as #!/usr/bin/env python, as this instructs the script to respect the active virtual environment.*
Could we clarify the following?
- env is a system binary in /usr/bin available in most Linux distros that searches $PATH for strings containing the provided argument and returns the first instance it finds. In the above syntax, env will search for the first instance of python in $PATH and return it. -
The shebang #! /usr/bin/env python works equally well in Linux when a script is to be run from within an activated virtual environment or when a default python installation is to be used and it is uncertain whether the python interpreter exists in /bin , /usr/bin , /usr/local/bin, or another custom path. -
Since python may be an alias for python2 or python3 (typically, it is an alias for python2), the developer may choose to be specific and use the shebang #!/usr/bin/env python3 where desired. The Windows py launcher also accepts this shebang and searches the application directory, current directory, system directories, and PATH for “python.exe”. However, note that using python3 instead of python will not work as expected because it will instead use the preferred version of python 3.x that's installed and not look through directories.
Although PEP 394 is geared towards Linux users, those unfamiliar with Linux don't know what env is or what it does. I've posted this issue here <https://discuss.python.org/t/pep-394-clarify-bullet-for-usr-bin-env-python/7953> and give some more information. Guido said I should post this on python-dev, but I'm still waiting for access.
Does anyone have any thoughts?
Thank you, Adam Hendry
---------------------------------------------------------------------- _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/CKD2WS... Code of Conduct: http://python.org/psf/codeofconduct/
participants (2)
-
Adam Hendry
-
Stephen J. Turnbull