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 support for listing system toolchains #4172

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Add support for listing system toolchains #4172

merged 1 commit into from
Jun 13, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jun 9, 2024

Includes system interpreters in uv toolchain list.

This includes a refactor of find_toolchain to support iterating over all toolchains
that match a request rather than ending earlier.

@zanieb zanieb mentioned this pull request Jun 9, 2024
@zanieb zanieb force-pushed the zb/toolchain-v-i branch 2 times, most recently from b3f708c to 943c963 Compare June 10, 2024 14:14
Base automatically changed from zb/toolchain-v-i to main June 10, 2024 14:22
@zanieb zanieb changed the title Add support for listing all available toolchains Add support for listing system toolchains Jun 10, 2024
@zanieb zanieb force-pushed the zb/find-toolchains branch 3 times, most recently from 630f39a to b3921b6 Compare June 11, 2024 19:08
@zanieb
Copy link
Member Author

zanieb commented Jun 11, 2024

Example

❯ uv toolchain list
cpython-3.12.3-macos-aarch64-none	/opt/homebrew/opt/[email protected]/bin/python3.12
cpython-3.12.3-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.12.3-macos-aarch64-none/install/bin/python3
cpython-3.11.9-macos-aarch64-none
cpython-3.10.14-macos-aarch64-none
cpython-3.9.19-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.9.19-macos-aarch64-none/install/bin/python3
cpython-3.9.6-macos-aarch64-none	/Library/Developer/CommandLineTools/usr/bin/python3
cpython-3.8.19-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.8.19-macos-aarch64-none/install/bin/python3
❯ uv toolchain list --all-platforms
cpython-3.12.3-windows-x86_64-none
cpython-3.12.3-macos-x86_64-none
cpython-3.12.3-macos-aarch64-none	/opt/homebrew/opt/[email protected]/bin/python3.12
cpython-3.12.3-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.12.3-macos-aarch64-none/install/bin/python3
cpython-3.12.3-linux-x86_64-musl
cpython-3.11.9-windows-x86_64-none
cpython-3.11.9-macos-x86_64-none
cpython-3.11.9-linux-x86_64-musl
cpython-3.10.14-windows-x86_64-none
cpython-3.10.14-macos-x86_64-none
cpython-3.10.14-linux-x86_64-musl
cpython-3.9.19-windows-x86_64-none
cpython-3.9.19-macos-x86_64-none
cpython-3.9.19-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.9.19-macos-aarch64-none/install/bin/python3
cpython-3.9.19-linux-x86_64-musl
cpython-3.9.6-macos-aarch64-none	/Library/Developer/CommandLineTools/usr/bin/python3
cpython-3.8.19-windows-x86_64-none
cpython-3.8.19-macos-x86_64-none
cpython-3.8.19-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.8.19-macos-aarch64-none/install/bin/python3
cpython-3.8.19-linux-x86_64-musl
cpython-3.7.9-windows-x86_64-none
cpython-3.7.9-macos-x86_64-none
❯ uv toolchain list --all-versions
cpython-3.12.3-macos-aarch64-none	/opt/homebrew/opt/[email protected]/bin/python3.12
cpython-3.12.3-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.12.3-macos-aarch64-none/install/bin/python3
cpython-3.12.3-macos-aarch64-none
cpython-3.12.2-macos-aarch64-none
cpython-3.12.1-macos-aarch64-none
cpython-3.12.0-macos-aarch64-none
cpython-3.11.9-macos-aarch64-none
cpython-3.11.8-macos-aarch64-none
cpython-3.11.7-macos-aarch64-none
cpython-3.11.6-macos-aarch64-none
cpython-3.11.5-macos-aarch64-none
cpython-3.11.4-macos-aarch64-none
cpython-3.11.3-macos-aarch64-none
cpython-3.11.1-macos-aarch64-none
cpython-3.10.14-macos-aarch64-none
cpython-3.10.13-macos-aarch64-none
cpython-3.10.12-macos-aarch64-none
cpython-3.10.11-macos-aarch64-none
cpython-3.10.9-macos-aarch64-none
cpython-3.10.8-macos-aarch64-none
cpython-3.10.7-macos-aarch64-none
cpython-3.10.6-macos-aarch64-none
cpython-3.10.5-macos-aarch64-none
cpython-3.10.4-macos-aarch64-none
cpython-3.10.3-macos-aarch64-none
cpython-3.10.2-macos-aarch64-none
cpython-3.10.0-macos-aarch64-none
cpython-3.9.19-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.9.19-macos-aarch64-none/install/bin/python3
cpython-3.9.19-macos-aarch64-none
cpython-3.9.18-macos-aarch64-none
cpython-3.9.17-macos-aarch64-none
cpython-3.9.16-macos-aarch64-none
cpython-3.9.15-macos-aarch64-none
cpython-3.9.14-macos-aarch64-none
cpython-3.9.13-macos-aarch64-none
cpython-3.9.12-macos-aarch64-none
cpython-3.9.11-macos-aarch64-none
cpython-3.9.10-macos-aarch64-none
cpython-3.9.7-macos-aarch64-none
cpython-3.9.6-macos-aarch64-none	/Library/Developer/CommandLineTools/usr/bin/python3
cpython-3.9.6-macos-aarch64-none
cpython-3.9.5-macos-aarch64-none
cpython-3.9.4-macos-aarch64-none
cpython-3.9.3-macos-aarch64-none
cpython-3.9.2-macos-aarch64-none
cpython-3.8.19-macos-aarch64-none	/Users/zb/Library/Application Support/uv/toolchains/cpython-3.8.19-macos-aarch64-none/install/bin/python3
cpython-3.8.19-macos-aarch64-none
cpython-3.8.18-macos-aarch64-none
cpython-3.8.17-macos-aarch64-none
cpython-3.8.16-macos-aarch64-none
cpython-3.8.15-macos-aarch64-none
cpython-3.8.14-macos-aarch64-none
cpython-3.8.13-macos-aarch64-none
cpython-3.8.12-macos-aarch64-none

@zanieb
Copy link
Member Author

zanieb commented Jun 11, 2024

Will probably add --all-architectures and --all-libc flags eventually because they seems more useful than --all-platforms but I'm going to wait. What I did here felt like the minimum necessary for decent output.

@zanieb zanieb marked this pull request as ready for review June 11, 2024 19:12
@zanieb zanieb added the preview Experimental behavior label Jun 12, 2024
@zanieb zanieb force-pushed the zb/find-toolchains branch 3 times, most recently from f0a6021 to 0c2856d Compare June 13, 2024 13:19
@zanieb zanieb requested a review from BurntSushi June 13, 2024 13:19
@BurntSushi
Copy link
Member

Still reviewing, but the first question in my head when I see the output is: why do some installations have a path and some don't?

@zanieb
Copy link
Member Author

zanieb commented Jun 13, 2024

The ones that don't have a path aren't downloaded yet. Couldn't find a nice way to represent that yet.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

LGTM!

Concerning the output, I think my confusion stems from a very strong a priori bias that the list I'm looking at reflects toolchains that are already installed. Maybe I'm an odd duck and most won't have that bias, and perhaps therefore most won't be confused. Not sure.

One idea is to add something like <available to install> or something for each toolchain that is available but not installed. But... I could see that being noisy. And it's just kind of redundant info repeated a lot.

I think I still personally like listing only installed toolchains by default, and having an opt-in flag like --available or whatever that shows the bigger output.

crates/uv-toolchain/src/discovery.rs Outdated Show resolved Hide resolved
crates/uv/src/commands/toolchain/list.rs Outdated Show resolved Hide resolved
crates/uv/src/commands/toolchain/list.rs Show resolved Hide resolved
Includes system interpreters in `uv toolchain list`.

This includes a refactor of `find_toolchain` to support iterating over all toolchains
that match a request rather than ending earlier.
@zanieb
Copy link
Member Author

zanieb commented Jun 13, 2024

Thanks for the review.

I think you have some fair concerns about the output. Maybe I'm over-optimizing on the fact that we dynamically fetch requested interpreters so it doesn't really matter if something is installed or not because you can uv run --python 3.12.3 regardless. I'm trying to do a bit of a paradigm shift here to reflect that so maybe I'll merge as is and we can tweak it based on feedback? I'm biasing towards trying something new during this experimental phase.

I added the <download available> output you mentioned, I think it's reasonable. A little annoying if you're trying to parse the output, I guess.

@zanieb
Copy link
Member Author

zanieb commented Jun 13, 2024

Maybe we shouldn't show paths by default and just exclude system interpreters that overlap with managed interpreters by default. Then the output would be nice and simple like I want :) I will explore... probably as a follow-up.

@BurntSushi
Copy link
Member

I'm trying to do a bit of a paradigm shift here to reflect that so maybe I'll merge as is and we can tweak it based on feedback? I'm biasing towards trying something new during this experimental phase.

Totally in favor of this! If we're going to try something new, now is definitely the time.

Maybe we shouldn't show paths by default and just exclude system interpreters that overlap with managed interpreters by default. Then the output would be nice and simple like I want :) I will explore... probably as a follow-up.

👍

@zanieb zanieb merged commit 89daa51 into main Jun 13, 2024
47 checks passed
@zanieb zanieb deleted the zb/find-toolchains branch June 13, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants