Skip to content
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

Add PowerShell snippets for postinstall #22

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

tats-u
Copy link
Contributor

@tats-u tats-u commented Jul 16, 2022

#66

This PR allows Windows users to activate poery command without forcing them to google how to do it.

@vercel
Copy link

vercel bot commented Jul 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
install-python-poetry-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 11:11pm

@tats-u
Copy link
Contributor Author

tats-u commented Jul 17, 2022

Poetry (1.1.14) is installed now. Great!
To get started you need Poetry's bin directory (C:\Users\runneradmin\AppData\Roaming\Python\Scripts) in your `PATH`
environment variable.
You can choose and execute one of the following commands in PowerShell:
A. Appends the bin directory to your user environment variable `PATH`:
```
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";C:\Users\runneradmin\AppData\Roaming\Python\Scripts", "User")
```
B. Tries to appends the bin directory to PATH every when you run PowerShell (>=6 recommended):
```
echo 'if (-not (Get-Command poetry -ErrorAction Ignore)) { $env:Path += ";C:\Users\runneradmin\AppData\Roaming\Python\Scripts" }' | Out-File -Append $PROFILE
```
Alternatively, you can call Poetry explicitly with `C:\Users\runneradmin\AppData\Roaming\Python\Scripts\poetry`.
You can test that everything is set up by executing:
`poetry --version`

@johnthagen
Copy link
Contributor

johnthagen commented Jul 24, 2022

For reviewers, here is a useful StackOverflow answer on the subject: https://stackoverflow.com/a/2571200

Copy link
Contributor

@johnthagen johnthagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Disclaimer, not a Poetry dev]

First off, thank you for making this PR. I think this is an important step to easing new Windows users into Poetry.

My personal feedback is that we should try to keep this simpler. The installer already prints quite a lot of text and having multiple Powershell commands I think could overwhelm the target audience.

If we look at the Unix variant of this for inspiration, it is very simple:

POST_MESSAGE_CONFIGURE_UNIX = """
Add `export PATH="{poetry_home_bin}:$PATH"` to your shell configuration file.
"""

I would recommend we shorten this message to:

POST_MESSAGE_CONFIGURE_WINDOWS = """
Execute the following in Powershell:

[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";{poetry_home_bin}", "User")
"""

@johnthagen
Copy link
Contributor

johnthagen commented Jul 24, 2022

I tested Option A in this PR in a clean Windows 10 VM, and it worked as expected. 🚀

@tats-u
Copy link
Contributor Author

tats-u commented Jul 24, 2022

Unix OSes have no choice other than editing profile files for their shells, so how to activate Poetry can be kept simple.

In contrast of this, Windows has the built-in manager of environment variables.
PowerShell and CMD have profiles like shells for Unix.
This is why 2 option can be provided for Windows.

@johnthagen
Copy link
Contributor

@neersighted Would you be willing to review this PR? I personally think it would be important before the upcoming 1.2 final release. ❤️

install-poetry.py Outdated Show resolved Hide resolved
install-poetry.py Outdated Show resolved Hide resolved
@abn abn merged commit 6027c8e into python-poetry:main Nov 21, 2024
50 checks passed
@tats-u tats-u deleted the windows-snippets branch November 21, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants