-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Shell completion on Bash for Windows #2352
Conversation
Hi, thanks for the patch! The Thanks again for the contribution. I look forward to see this propagated into Pipenv! |
Ok, I'll send the patch upstream to click-completion. I noticed there's a big version difference between the vendorized click-completion (0.21) and the latest release (0.31). Hopefully that won't be an obstacle to pulling the updated click-completion. Meanwhile, any pipenv bash on windows user can use use my patch on their local installation. |
There's also a simple bypass that you can use where you call
This will force pipenv environments.py to detect the shell as bash instead of bash.exe. |
It’s probably alright, I don’t think they changed their API, so we can just upgrade all the way to latest (I think). Send a message when it’s done and we can try it out! |
The irony of it is, click-completion already does the right thing (removing the .exe) when using its get_auto_shell capability instead of passing the shell as a param like pipenv does, but that adds psutil as a dependency, which I'm sure you're reluctant to do. |
To say we don’t want to bring in psutil is a huuuge understatement. For reference: https://github.com/pypa/pipenv/blob/master/tasks/vendoring/patches/patched/pew_psutil.patch was implemented just to remove psutil and it does the exact same thing (but much faster) Hey @uranusjr have you ever looked at click completion? Take a look at this: pipenv/pipenv/vendor/click_completion.py Line 410 in 4425644
|
I feel fortunate we already implemented this… that is not exactly inspiring. |
Reading the source it’s not even that complication. I bet I can come up with something tonight. |
It turns out we can avoid psutil without even needing to patch anything. I do want to improve our own shell detection code first before doing it, however. I think I will make a project out of this. |
@uranusjr I've talked with the click-completion developer and they've clarified that 'bash.exe' is not a valid value for the shell parameter. So code calling click-completion.get_code should make sure to provide the right value, which is just 'bash'. How do you feel about a patch for pipenv that fixed this ? I could write that. It shouldn't interfere with your work on remaking the shell detection code, I think. |
The patch I'm talking about is necessary because in environments.py there's this line:
SHELL is set to |
@ociule We should strip the extension before sending it to Click-Completion (so |
We never had any speed issue with psutil speed, at least for the very simple usage we have. It is an optional dependency in our code, just because it is not always distributed in binary version in pipy. Anyway, we could has well use shelligham for what we do. It seems broken with python 2 though, and I can't find the github (or any other) repository. @uranusjr could you point to the shelligham project page? |
BTW, I'm one of the click-completion developers :) |
@glehmann Of course, here it is: https://github.com/sarugaku/shellingham For myself the problem of psutil is not speed, but it has C dependencies. Pipenv tries to vendor dependencies if possible, and C dependencies are difficult to handle :( |
Currently, shell completion is not supported on Bash for Windows.
If we try
pipenv --completion
we get a message saying "bash.exe is not supported"I've patched pipenv/vendor/click_completion.py to support Bash completion.
All that was needed was enabling the generation of the bash script on bash.exe. The generated script already worked.