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.
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
Fix direct usage of pip.pyz example #12043
Fix direct usage of pip.pyz example #12043
Changes from 4 commits
66903a3
5102ca4
881da76
3db673f
39431b5
b1ea8c1
cebb9f1
b96b21d
8fe45a1
8901f87
a3ce5aa
2d6e6be
67f79f2
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.
On windows this needs to register the .pyz extension and associate it to some python interpreter? Does this support virtual environments?
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.
Yeah, that's done during installation. Considering that it's based on
py
launcher, I'm guessing it's only done when that is installed.Yes,
py
launcher uses the activated virtual environment if a specific Python version isn't specified, which it isn't when running the.pyz
file directly.During my testing, I found out that zipapps don't work as great on Windows as they do on Unix since they're only based on the registered extensions and therefore aren't recognized transparently everywhere (e.g.
subprocess.run(["pip.pyz"])
doesn't work, running it in PowerShell causes Command Prompt window to open instead of using the existing terminal).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.
Correct. On Windows, I would typically recommend using
py C:\Path\To\pip.pyz
, or using a launcher executable. Users of thescoop
package manager on Windows can use something like https://github.com/pfmoore/scoop-enk/blob/master/bucket/pip.json (or just register that bucket and use it directly 🙂)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.
Can this be fixed to say
py .\pip.pyz
?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.
Just to make sure I understand you correctly, you want both of these invocations to use
py pip.pyz
?Instead of being different how it's on Linux/MacOS:
Such change would be fine for me, I just want to make sure that's what you want. In such a case, I should probably add some text before the command on the second Windows tab to minimize the user confusion though. Or maybe keep only a single Windows tab for that whole text there and only show a single command on the Windows tab?
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.
Ah, that's a good point. I hadn't spotted that this was the "if run directly" section. I honestly don't know how we explain what's needed simply here. You're correct that it shouldn't use
py
as that's not "running it directly".I don't think the pip documentation is the right place to get into how to set your system up to automatically run
.pyz
files, but I also don't think we're doing anyone any favours by giving a command that won't work for a non-trivial subset of users 🙁Maybe we just remove the example invocation altogether, just leaving the statement "If run directly then the currently active Python interpreter will be used". It's a little cryptic, leaving the user to infer what "running directly" means, but at least it isn't flat-out incorrect.
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 committed what I think would be the least cryptic option. It isn't quite what you proposed so let me know what you think about that:
https://pip--12043.org.readthedocs.build/en/12043/installation/#standalone-zip-application
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.
Personally, I don't like it, as the way the second example disappears when I switch from Linux to Windows is extremely disconcerting.
OK, this all sucks. I'm going to say let's just go back to using plain
.\pip.pyz
on Windows, and hope we don't get too many confused Windows users asking us how to register the.pyz
extension. I don't like it, but all of the alternatives seem worse to me.Maybe we just add a note - something like
that would be enough?
By the way, I just noticed that the Windows version,
C:> py pip.pyz --help
renders in italics, for some weird reason. It shouldn't do that. I have no idea why it happens - other console commands don't display like that.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.
Seems fine to me, will change it to that in a moment.
That's partially on me, I tried to make it consistent with the prefix used by
{pip-cli}
and I removed the\
fromC:\>
which seems to get rendered differently.C:\>
is actually more correct anyway since that's how Command Prompt shows the root drive path so I'll change it back.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.
Okay, I think it looks good now. Turns out that the italics was caused by the
console
lexer being used for the code block. I changed it to the properdoscon
. Btw, the same problem can also be observed in user guide document.As for the note, I added it as a separate line in the Windows tab. To me, it looks less disconcerting when switching tabs, see:
Linux tab
Windows tab with one paragraph
Windows tab with two paragraphs