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

Skip python.exe with uv install python --default #9817

Open
Vynce opened this issue Dec 11, 2024 · 4 comments
Open

Skip python.exe with uv install python --default #9817

Vynce opened this issue Dec 11, 2024 · 4 comments
Labels
configuration Settings and such

Comments

@Vynce
Copy link

Vynce commented Dec 11, 2024

I love the uv python install --default feature (#8650), but it creates a python.exe executable in addition to a python3.exe executable. Unfortunately, we still need python.exe to resolve to a Python 2.7 interpreter for the time being. Would you be willing to add a uv.toml setting or an alternative --default-py3only arg or something that limits the feature to only managing python3.exe. Similar issue on Linux, but I'm specifically looking at the Windows behavior.

@zanieb
Copy link
Member

zanieb commented Dec 11, 2024

Oof. Hm.. I guess a uv.toml setting is less controversial to me (it seems niche for the CLI), but we don't have Python install settings there yet.

Would an environment variable be sufficient?

Unfortunately, we still need python.exe to resolve to a Python 2.7 interpreter for the time being.

Would it be feasible to specify the full path to your 2.7 interpreter? Or adjust the PATH in that context?

Thanks for reporting!

@zanieb zanieb added the configuration Settings and such label Dec 11, 2024
@Vynce
Copy link
Author

Vynce commented Dec 11, 2024

Would an environment variable be sufficient?

Yeah, that could work. We could set that globally in our uv installation script (not that different from setting it in the uv.toml). We're already setting the default index url and python-install-mirror in the uv.toml.

Would it be feasible to specify the full path to your 2.7 interpreter? Or adjust the PATH in that context?

Not easily. We need to support a mixed environment where legacy scripts expect python to be Python 2.7. I really want ~/.local/bin to be first in the PATH since that's where all the uv goodies live, but a python.exe there will shadow others later in the PATH. Putting Python 2.7 before ~/.local/bin on the PATH could work, but introduces other complexities with managing PATH order. Dealing with all this nonsense with Python on Windows is why I'm so excited about uv 😄.

Also feel free to decide that uv isn't going to go out of its way to support coexistence with Python 2. That'll make me sad because --default is exactly the feature I want to use to manage Python 3 versions going forward, but I can create my own python3.exe symlink that points to the desired uv trampoline executable instead or come up with other workarounds 😊.

@zanieb
Copy link
Member

zanieb commented Dec 11, 2024

Another question, is there a way you're invoking python.exe for Python 2 that would inform us that we should pass that invocation through to another executable?

I think some flag here is reasonable, just need to figure out how to express it.

@Vynce
Copy link
Author

Vynce commented Dec 11, 2024

Python 2 is typically invoked via the shebang in the the Python script (e.g. #!/usr/bin/env python) in a Git Bash (aka msys bash) shell on Windows. We do it this way so it works the same on Linux and macOS. There are some shell scripts that explicitly call Python 2 scripts directly, like python myscript.py. Both cases assume that python is on the PATH and resolves to Python 2.

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

2 participants