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

Ignore Python 2 installations when querying for interpreters #1905

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Feb 23, 2024

Summary

Fixes #1693

uv currently fails when a user has python 2 or older installed on their system without a python3 or python3.exe on their path because
the get_interpreter_info.py script fails executing (it uses some Python 3+ APIs).

This PR fixes this by:

  • Returning an explicit error code in get_interpreter_info if the Python version isn't supported
  • Skipping over this error in python_query if the user requested ANY python version or a version >= 3.
  • Error if the user requested a Python 2 version.

Test Plan

Error if the user requests a legacy python version.

uv venv -p 2
  × Python 2 or older is not supported. Please use Python 3 or newer.

Ignore any python 2 installation when querying newer python installations (using v4 here because I have python3 on the path and that takes precedence over querying python)

 uv_interpreter::python_query::find_python selector=Major(4)
      0.005541s   0ms DEBUG uv_interpreter::interpreter Detecting markers for: /home/micha/.pyenv/shims/python
      0.059730s  54ms DEBUG uv_interpreter::python_query Found a Python 2 installation that isn't supported by uv, skipping.
      0.059983s  54ms DEBUG uv_interpreter::interpreter Using cached markers for: /usr/bin/python
  × No Python 4 In `PATH`. Is Python 4 installed?

@MichaReiser MichaReiser added the bug Something isn't working label Feb 23, 2024
@MichaReiser MichaReiser marked this pull request as ready for review February 23, 2024 08:49
@konstin konstin merged commit 829e147 into main Feb 23, 2024
7 checks passed
@konstin konstin deleted the ignore-python-2 branch February 23, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad error message when python query encounters python 2
2 participants