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

System python install to an exact path #11933

Open
ThermodynamicBeta opened this issue Mar 3, 2025 · 4 comments
Open

System python install to an exact path #11933

ThermodynamicBeta opened this issue Mar 3, 2025 · 4 comments
Labels
enhancement New feature or improvement to existing functionality

Comments

@ThermodynamicBeta
Copy link

Summary

I maintain a project at work where we're considering using uv to manage system python versions.

I would like to install a system python to a path like C:\Python310\python.exe, that is where it is now when we install through the official python installer.

I think this is a bit of a hassle with uv right now, you need to use --install-dir and then set an environment variable (which is a pain on Windows), and then all python installs will go there, not just one.

Using the currently available method, it also would be installed to C:\Python310\cpython-3.10.16-windows-x86_64-none\python.exe, which is long and eliminates some of the convenience of installing.

Distilling what I said above, this is what i want

  • Be able to install a system python to a specified folder with no long-python-version-name
  • Have uv be able to detect that python without an environment variable set (how does py -0p do it? Can't uv just add it to the PATH?)

Example

User runs
uv pip install 3.10 --install-dir C:\Python310\

and the directory looks as if they installed it with the official Python installer, and it's now available for use with uv python list

@ThermodynamicBeta ThermodynamicBeta added the enhancement New feature or improvement to existing functionality label Mar 3, 2025
@zanieb
Copy link
Member

zanieb commented Mar 3, 2025

py relies on versions being added to the Windows registry. Which we do since #10634

uv python install --preview --default can be used to install the executable (i.e., python.exe) into a directory (presumably on the PATH). UV_PYTHON_BIN_DIR can be used to target a different directory. Is that what you're looking for?

If not, can you explain more of the motivation for a specific target path?

@ThermodynamicBeta
Copy link
Author

ThermodynamicBeta commented Mar 3, 2025

Just now, I ran uv python install 3.9 --default --preview --install-dir C:\Python39

This installed it into C:\Python39\cpython-3.9.21-windows-x86-none\, which is not what I wanted. I want everything that is in that folder to be in C:\Python39. I get that what uv means by this flag is different from what I want from it, i.e. this is a central directory for all python versions for uv, but I want to force a directory for one specific installation like I could with the official Python installer. That is the feature request.

Separately, I was under the impression that running uv python install with the --install-dir flag would make that python version not discoverable to uv python list, unless an environment variable is set. That is what I got from the documentation:

Image

This does not actually seem to be the case, after running uv python install 3.9 --default --preview --install-dir C:\Python39,
that version does show up in my uv python list, even in a new terminal:

Image

Could you please explain why this is different from what the documentation says? Is it using the Windows registry, or the PATH? Would it be different on Linux?

@zanieb
Copy link
Member

zanieb commented Mar 3, 2025

It's probably discovered via the registry, which was a recent change and did not take into account that the --install-dir documentation would need to be updated. It would not be found on Linux unless it's on the PATH.

This installed it into C:\Python39\cpython-3.9.21-windows-x86-none, which is not what I wanted. I want everything that is in that folder to be in C:\Python39. I get that what uv means by this flag is different from what I want from it, i.e. this is a central directory for all python versions for uv, but I want to force a directory for one specific installation like I could with the official Python installer. That is the feature request.

I understand this is the request. Why do you want it?

@ThermodynamicBeta
Copy link
Author

As a long-time python user, sometimes I just really need to be 100% sure which python version I'm using, so I invoke it with the full path. Not being able to control what the final installation directory is named gets in the way of this. I could definitely see this being unnecessary from your POV, because ideally you can do everything you want through uv. It just seems like this convenient feature of the original Python installer could be useful to some people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants