GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — adds better windows shell support by bmarroquin · Pull Request #5053 · python-poetry/poetry

Conversation

@bmarroquin

@bmarroquin bmarroquin commented Jan 17, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Pull Request Check List

This change resolves a lot duplicated issues.
Resolves: #5050, Resolves #4996, Resolves #4993, Resolves #4560, Resolves #2793, Resolves #2156, Resolves #1642

  • Added tests for changed code.
  • Updated documentation for changed code.

There are not tests for activating shells and this doesn't require a change in documentation. This lines up Windows behavior with the documentation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jrobbins-LiveData reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bmarroquin
adds better windows shell support
57450f2
@finswimmer
finswimmer requested a review from a team January 17, 2022 20:17
neersighted
neersighted requested changes Jan 18, 2022
View reviewed changes
Comment thread src/poetry/utils/shell.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

jrobbins-LiveData
jrobbins-LiveData reviewed Jan 18, 2022
View reviewed changes
Comment thread src/poetry/utils/shell.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

jrobbins-LiveData
jrobbins-LiveData reviewed Jan 18, 2022
View reviewed changes
Comment thread src/poetry/utils/shell.py
if WINDOWS:
return env.execute(self.path)
if self._name == "powershell":
args = ["-NoExit", "-File", str(activate_path)]

@jrobbins-LiveData jrobbins-LiveData Jan 18, 2022

Copy link
Copy Markdown

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.

Subjective opinion: I like launching with -nologo to not have to see

PowerShell 7.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

each time.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

KotlinIsland and daviewales reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

@neersighted neersighted Jan 18, 2022

Copy link
Copy Markdown
Member

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.

Given that it is cosmetic, I'd rather not add more arguments past the bare minimum, personally.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jrobbins-LiveData jrobbins-LiveData Jan 18, 2022

Copy link
Copy Markdown

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.

Understood. It is definitely subjective on my part -- I like the "clean sheet" in front of me after typing poetry shell, but typing cls isn't a big deal.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jrobbins-LiveData

jrobbins-LiveData commented Jan 18, 2022

Copy link
Copy Markdown

In my "wish list" for a nicer Windows cmd.exe experience in Poetry, there are only two items you didn't cover in your excellent PR.

  1. command history (up/down arrow traversal of typed commands) in a Windows Terminal cmd.exe launched by poetry shell. This thread discusses the problem and offers a solution I have tested with poetry. If you added the following to Shell's __init__ method, using the implementation given in that thread for set_console_history_info(), you'd ensure that console command history will work in the Poetry shell. Without this, poetry shell inside Windows Terminal cmd.exe is markedly less usable.
        if WINDOWS:
            set_console_history_info()
  1. this one is a more subjective "nice to have" feature: while executing the relevant activate script, it is nice to set the title of the console to the name of the folder. In the case of cmd.exe, this is simply adding via && another command to the args, e.g. "title", env.path.name. In the case of powershell/pwsh, it the added command includes '& {$host.UI.RawUI.WindowTitle = "%s"}' % env.path.name
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@neersighted

neersighted commented Jan 18, 2022

Copy link
Copy Markdown
Member

I'm a little leery of doing too much -- poetry shell is intentionally very minimal. This is a lesson learned from the pain and breakage that came from Pipenv's customized and curated, but ultimately brittle shell experience.

That being said, I'd still consider the suggestions made by @jrobbins-LiveData if they are added to this PR and don't look to be a big maintenance burden, since they seem to be minor and relatively stable.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jrobbins-LiveData

jrobbins-LiveData commented Jan 18, 2022

Copy link
Copy Markdown

I agree, @neersighted, regarding the minimalist approach. Of all my feedback, I think I'd prioritize pwsh.exe support.

As to command history support, technically perhaps that's more properly a Windows Terminal concern. The reason I bring it up here is that if one "manually" simply runs Scripts\activate.bat in one's existing shell, one gets activation without losing command history because it is still the same shell. poetry shell, by necessity, launches a new shell, and so hits a Windows Terminal default limit, which is fixed by set_console_history_info().

In a regular command prompt window (not Windows Terminal), one can address this problem in its Properties page in the spot I've circled
image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jrobbins-LiveData

jrobbins-LiveData commented Jan 19, 2022

Copy link
Copy Markdown

@neersighted , perhaps there could be an optional "user script" hook (configured via poetry's config mechanism?) , that the internal process.run would call inline if configured? This would allow for setting the title, configuring the command history buffer, etc, if the user wanted to configure the logic, without overly burdening the poetry code with taking on too much?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jrobbins-LiveData jrobbins-LiveData mentioned this pull request Jan 19, 2022
conpty uses default history buffer length microsoft/terminal#2558
Open
@bmarroquin
Updates per review
c566e13
uses subprocess.run()
adds support for pwsh
@bmarroquin

bmarroquin commented Jan 19, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@neersighted updated the PR. Only handled the changes that keep everything minimal.
There is a side effect that pwsh might work for non-windows environments. PR #5047 was trying to enable that. I did not test the change on non-windows environments.

@jrobbins-LiveData Thanks for all the feedback, appreciate it. I know this doesn't cover your wish list, but there are some minor upgrades 😊.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bmarroquin
bmarroquin requested a review from neersighted January 20, 2022 05:58
neersighted
neersighted requested changes Jan 20, 2022
View reviewed changes
Comment thread src/poetry/utils/shell.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bmarroquin
changes how command list is built
e3fae84
@bmarroquin
bmarroquin requested a review from neersighted January 22, 2022 02:12
neersighted
neersighted approved these changes Jan 22, 2022
View reviewed changes
@neersighted
neersighted merged commit 28d05d0 into python-poetry:master Jan 22, 2022
@kkthxbye kkthxbye mentioned this pull request Jan 22, 2022
Add "pwsh" to shell.py #5047
Closed
@finswimmer finswimmer mentioned this pull request Mar 6, 2022
Release 1.2.0b1 #5280
Merged
@bmarroquin bmarroquin mentioned this pull request Jul 3, 2022
Poetry does not show the virtualenv prefix on PowerShell #5824
Closed
3 tasks done
@github-actions

github-actions Bot commented Feb 29, 2024

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@neersighted neersighted neersighted approved these changes
+1 more reviewer
@jrobbins-LiveData jrobbins-LiveData jrobbins-LiveData left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

(🐞) deactivate-ing a poetry shell doesn't work (on windows?) PowerShell prompt string not modified by poetry shell Virtual Environment Does Not Appear Next to Path in Shell Shell prompt not reflecting virtual environment on Windows 10 Update prompt environment variable when opening shell
(🐞) venv info not showing in powershell and cmd prompt What is the purpose of the "poetry shell" command?

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bmarroquin @jrobbins-LiveData @neersighted
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.