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

Clarify section on installing into arbitrary Python environments #4034

Merged

Conversation

dpoznik
Copy link
Contributor

@dpoznik dpoznik commented Jun 5, 2024

Summary

This meta-PR includes some suggestions for the docs on installing into arbitrary Python environments.

It targets the branch in #4031 and is a response to #3951 (comment).

Specifically, it:

install into the environment linked to the `/path/to/python` interpreter.

For convenience, `uv pip install --system` will install into the system Python environment, as an
approximate shorthand for, e.g., `uv pip install --python=$(which python3)`. Though we generally
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved --python=$(which python3) to previous paragraph, since no longer equivalent to --system.

Copy link
Member

Choose a reason for hiding this comment

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

It's only saying it's an "approximate" shorthand. I think it's rare that your python is a shim which automatically activates environments on invocation? Just responding to your comment though I might be okay with where it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only saying it's an "approximate" shorthand.

Sure, I get that. I guess what was confusing for me was than in uv<0.2, --system seemed more or less equivalent to --python=$(which python3), whereas in uv>=0.2, this was no longer the case, at least for my use-case. Moreover, it's not currently clear in the text on main under which conditions the equivalence holds.

I think it's rare that your python is a shim which automatically activates environments on invocation?

Hmm, as a pyenv-virtualenv user, this is always the case for me, but I'm not sure how prevalent this is, writ large.

I guess the main suggestion here is to provide clarity as to what --system does: perhaps including how it may be similar to --python=$(which python3) and how it differs.

README.md Outdated
Comment on lines 187 to 188
current interpreter on the `PATH`. Another way to install into the environment linked to the
current interpeter is to invoke `uv` as a module (e.g., `python -m uv pip install`).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added python -m uv suggestion gleaned from https://github.com/astral-sh/uv/releases/tag/0.2.0.

Copy link
Member

Choose a reason for hiding this comment

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

I'm hesitant to suggest this since it's slower than using uv directly (you need to pay the cost of Python interpreter startup). Might be worth saying something about which interpreter is used in this case regardless though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, gotcha. Sorry, I didn't appreciate that. Thanks for the heads-up. I'll amend...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sorry. I didn't see your force-push. Will amend again...

README.md Outdated
Comment on lines 199 to 202
Unless the `--python` argument is provided, or uv is invoked as a module,
uv will ignore any interpreters not in
[PEP 405 compliant](https://peps.python.org/pep-0405/#specification) virtual environments,
whether or not the `--system` flag is provided.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure how to interpret this:

When the --system flag is provided, uv will ignore any interpreters that are not in PEP 405 compliant virtual environments. Similarly, if the --system flag is not provided, uv will ignore any interpreters that are in not virtual environments.

This paragraph is a guess, but it may not be correct.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I find your paragraph confusing, but I inverted the clauses in mine (it's incorrect).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, since I didn't understand your version, I figured it must have included a misstatement :)
My text was an attempt to rephrase yours under the assumption it was correct as written, which means mine is also wrong. I'll revert and let you patch your version.

@dpoznik dpoznik marked this pull request as ready for review June 5, 2024 01:23
@zanieb zanieb self-assigned this Jun 5, 2024
@zanieb
Copy link
Member

zanieb commented Jun 5, 2024

Thanks for doing this! I'll give it a closer read through later today

@zanieb zanieb closed this Jun 5, 2024
@zanieb zanieb reopened this Jun 5, 2024
@zanieb
Copy link
Member

zanieb commented Jun 5, 2024

Sorry, wrong button :)

@zanieb zanieb force-pushed the zb/docs-discovery branch from 5baa2d2 to bf3911b Compare June 5, 2024 12:23
@dpoznik dpoznik force-pushed the zb/docs-discovery-dpoznik branch from 1c8c26b to 5e72133 Compare June 5, 2024 17:58
@zanieb zanieb merged commit 59e5bb6 into astral-sh:zb/docs-discovery Jun 6, 2024
45 checks passed
@dpoznik dpoznik deleted the zb/docs-discovery-dpoznik branch June 6, 2024 14:44
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.

2 participants