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 setting to manage preference for managed toolchains #4198

Closed
zanieb opened this issue Jun 10, 2024 · 8 comments
Closed

Add setting to manage preference for managed toolchains #4198

zanieb opened this issue Jun 10, 2024 · 8 comments
Labels
configuration Settings and such

Comments

@zanieb
Copy link
Member

zanieb commented Jun 10, 2024

Users should be able to opt in and out of managed toolchains, e.g.

managed-toolchains = always | preferred | fallback | never
@zanieb zanieb added configuration Settings and such preview Experimental behavior labels Jun 10, 2024
@zanieb
Copy link
Member Author

zanieb commented Jun 10, 2024

We could also frame this differently, like..

toolchain-discovery = prefer-system | prefer-managed | only-system | only-managed

@baggiponte
Copy link
Contributor

We could also frame this differently, like..

toolchain-discovery = prefer-system | prefer-managed | only-system | only-managed

What about?

toolchains = uv-first | system-first | managed-first | uv-only | system-only | managed-only

Or you could explicitly configure python providers like PDM. People might (and are) using tools like mise asdf pyenv.

@zanieb
Copy link
Member Author

zanieb commented Jun 20, 2024

What's the difference between uv-only and managed-only there?

I don't think we'll support discovery of Python interpreters in other tool's installation directories. It seems more reasonable to just expect them to be registered in the PATH (or, on WIndows, in the registry).

zanieb added a commit that referenced this issue Jun 20, 2024
)

Adds support for the toolchain discovery preferences outlined in
#4198 but we don't expose this to
users yet, I'll do that next to make it easier to review.

I've made some refactors in the toolchain discovery implementation to
enable this behavior and move us towards clearer abstractions. There's
still remaining work here, but I'd prefer tackle things in follow-ups
instead of expanding this pull request. I plan on opening a couple
before merging this.

I'd like to shift the public toolchain API to focus on discovering
either an **environment** or a **toolchain**. The first would be used by
commands that operate on an environment, while the latter would be used
by commands that just need an interpreter to create environments. I
haven't changed this here, but some of the refactors are in preparation
for supporting this idea.

In brief:

- We now allow different ordering of installed toolchain discovery based
on a `ToolchainPreference` type. This is the type we will expose to
users.
- `SystemPython` was changed into an `EnvironmentPreference` which is
used to determine if we should prefer virtual or system Python
environments.
- We drop the whole `ToolchainSources` selection concept, it was
confusing and the error messages from it were awkward. Most of the
functionality is now captured by the preference enums, but you can't do
things like "only find a toolchain from the parent interpreter" as
easily anymore.
@baggiponte
Copy link
Contributor

What's the difference between uv-only and managed-only there?

I don't think we'll support discovery of Python interpreters in other tool's installation directories. It seems more reasonable to just expect them to be registered in the PATH (or, on WIndows, in the registry).

Makes sense, but then I guess what's the difference between system python and other tools? In other words, brew python should just not come up, am I correct?

@zanieb
Copy link
Member Author

zanieb commented Jun 20, 2024

A "system" Python here is any Python toolchain installed on the system i.e. not being managed by uv. Brew Python will come up if it's on the PATH, but we won't try to discover it a Brew-specific location (as we won't, thusfar, attempt to discover pyenv Python in their storage directory)

@zanieb zanieb removed the preview Experimental behavior label Aug 20, 2024
@delfick
Copy link

delfick commented Sep 14, 2024

It would be useful to be able to tell uv to prefer using asdf/pyenv discovery/installation if that's available rather than only python-build-standalone

@zanieb
Copy link
Member Author

zanieb commented Sep 14, 2024

This issue is actually completed: https://docs.astral.sh/uv/reference/settings/#python-preference

Feel free to open a new one to track support for other managed Python distribution kinds, but we're pretty unlikely to support more.

@zanieb zanieb closed this as completed Sep 14, 2024
@delfick
Copy link

delfick commented Sep 14, 2024

sure, done #7400

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such
Projects
None yet
Development

No branches or pull requests

3 participants