Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PEP 394: Allow for more flexibility in handling /usr/bin/python #989
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
PEP 394: Allow for more flexibility in handling /usr/bin/python #989
Changes from 5 commits
68475c0
abf3bf3
4a4cdf7
36e61fa
268e96d
5e439bd
2e763f3
627ae44
4af8f14
8d88ea0
9546b15
fee50a4
4b20f8c
cca28c0
5d3e9d8
6dbfc2f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encourages actually makes me think it somehow makes it more likely. In fact, it just makes it so. I still consider ensures or makes sure to fit better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second sentence feels a little too imprecise. What exactly is an "older Linux distribution" and how many of them count as "most"? Perhaps:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we now recommending venvs for deployed scripts? Isn't that problematic? We've seen cases where venvs (IIRC, created with
virtualenv
notpython3 -m venv
, but I'm not sure about that), ties the installation to the Python version, so if you update the patched version, it breaks the venv.If we are recommending venv for deploys, are we positive they are stable, reliable, and relocatable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not writing Linux distro packages, you should absolutely be using a venv for everything.
You do need to use
pipx
, and you do need to reinstall them if you change Python versions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't assume the use of a venv, then everything is awful:
python
probably doesn't work on Windows (or runs something random)py
only works on Windowspython
is only reliably available inside a venvpython2
isn't reliably available anywherepython3
doesn't work on WindowsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, you run them using an explicit interpreter invocation, and forget about relying on shebang lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all feels like it's outside the scope of this PEP. With this view, we have to endorse a third party tool (
pipx
) and a deployment workflow, and teach people how to use virtual environments (and do they usevirtualenv
or$python -m venv
?). The reinstallation issue is problematic too. I don't know what any of this has to do with our recommendations to *nix distributions. If we really want to make these recommendations, we should do that in a separate PEP, IMHO.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thought: If you're using zip applications (pex, shiv), you should absolutely not be using venvs or
/usr/bin/env
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a response to the original draft of this PR, which advised all script publishers to unconditionally use
/usr/bin/python3
in their scripts, which I consider to be a bad default recommendation, since it breaks virtual environments./usr/bin/env python
is better generic advice, since it respects virtual environments, and leaves the choice of specifying something else in their shebang line to folks that specifically want to support running outside a venv, and should have a better idea of which kinds of environments they want to target, and hence which compatibility trade-offs they can make in choosing an exact spelling.Tools like
pipx
,zipapp
,shiv
etc all run an installer at some point, so they allow publishers to rely on console script definitions which write the shebang line at install time, rather than needing to rely on a hardcoded shebang line in the source file(s).The relevance of all this to PEP 394 is that platform providers need to account for publisher behaviour in designing their Python user experience, and that's easier for them to do if our advice to publishers is "assume platforms will either rely on a Python installer, so you can use generated console scripts, or else that they will make themselves look somewhat like a virtual environment".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest leaving out any mention of Python 4. 1) it can create FUD; 2) it's entirely vaporware; 3) we don't even know whether there will be a Python 4 or what it will look like. We can always add a Python 4 recommendation when the time comes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Good catch @warsaw