astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.4k stars 768 forks source link

uv python install at fixed location? #7710

Open mikeckennedy opened 1 month ago

mikeckennedy commented 1 month ago

Hi team,

I'm looking to rework the Talk Python installing Python guide to recommend uv rather than the myriad of options needed for all the platforms now.

One thing that seems clunky for uv python install is that I don't see a way to make a particular Python version the default one.

I'm not suggesting taking over the system Python or anything like that. But since each install managed by uv has a very specific path, e.g.:

.local/share/uv/python/cpython-3.12.6-macos-aarch64-none/bin/

Any update to the version (even build number) means whatever path you set in your system will become invalid.

For example, if we could uv python install 3.12.6 --primary or something, and have uv put a link or copy in some well known location such as .local/share/uv/python/primary then we can add that to the top of the path if we wish and when we run python/python3 it'll always find this one we designate as primary.

Any thinking along these lines?

BTW, yes, I know uv is venv-first and that's great. But if we are using it get Python on machines for super beginners, having the option to just type python to get a REPL and that sort of thing would be nice instead of full blown installers.

zanieb commented 1 month ago

I think you're sort of looking for https://github.com/astral-sh/uv/issues/6265

mikeckennedy commented 1 month ago

Hi @zanieb Yes, sort of. As long as we can get the shim at the very tip of the path. Xcode put Python in my path (3.9), Homebrew put 3.12 in my path. But I don't want either of those as the authoritative python for me. I'd like whatever I do from uv python install to be the one.

zanieb commented 1 month ago

We can't necessarily control what the tip of your path is, that's up to how you've configured your shell. We can warn if it's not going to be at the front though.

mikeckennedy commented 1 month ago

Hey @zanieb

Of course you can't control our paths, that's what ever we do to our machines.

My request here is that uv provide some mechanism to use a stable directory structure for a selected version of Python that it installed. In this way, we can put something fixed, rather than something that changes bi-monthly, into rc files or windows path settings that will stay working as Python evolves (3.13.0 -> 3.13.1, etc).

Shackelford-Arden commented 1 month ago

From reading around a bit, I'm getting the sense that a number of folks (myself included) seem to be generally in favor of getting the functionality/purpose that pyenv serves for a lot of us added to uv so that we can fully replace the need of pyenv.

Could still be in my own little dreamland though 😅

zanieb commented 1 month ago

We're working on it! See #7677

Shackelford-Arden commented 1 month ago

Ahh sweet. Hadn't found that one yet! Subscribed! 😏 Thanks

zanieb commented 1 week ago

Hey @mikeckennedy, this is sort of available in preview now via #8458 and https://github.com/astral-sh/uv/pull/8650

mikeckennedy commented 1 week ago

Thanks @zanieb Yes, uv python install --default sounds like what I was really searching for. I'm looking forward to playing with it soon!

mikeckennedy commented 1 week ago

Also, feel free to close this issue if you also think those features cover this use-case. I do think it will.