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

Support Python version number for --python arg when py launcher is not available #1342

Closed
huxuan opened this issue Apr 12, 2024 · 1 comment · Fixed by #1343
Closed

Support Python version number for --python arg when py launcher is not available #1342

huxuan opened this issue Apr 12, 2024 · 1 comment · Fixed by #1343
Labels
enhancement New feature or request

Comments

@huxuan
Copy link
Member

huxuan commented Apr 12, 2024

How would this feature be useful?

Currently, if we want to specify the python when py launcher is not available, we have to specify the whole command name, for example, we have to use --python python3.12 rather than --python 3.12. It would be more convenient if we can check python3.12 directly when the input value is 3.12.

Describe the solution you'd like

We can use packaging.version module to parse the input value and then compose the command f"python{python_version}" if it is a valid version number.

Describe alternatives you've considered

AFAIK, there is none.

BTW, I can submit a pull request if we agree on this change.

@Gitznik Gitznik added the enhancement New feature or request label Apr 12, 2024
@Gitznik
Copy link
Contributor

Gitznik commented Apr 12, 2024

I'm not against this. We already do the same thing the other way around, if py launcher is available.

I do not think it should result in a warning though and should not be endorsed. If python3.X is provided, it is very clear what executable we're using, as it has to be on the PATH. With just 3.X, this becomes less obvious. This is the same behavior as we have for py launcher versions, starting with python.

Also we have to fist check if the version without python is an available executable. Nothing is stopping a user from aliasing python3.10 to just 3.10, which might be a different one than the python3.10 on the PATH:

root@9fba04541a44:/# alias 3.10=python3
root@9fba04541a44:/# 3.10 -c "import sys;print(sys.version)"
3.10.13 (main, Feb 13 2024, 10:33:32) [GCC 12.2.0]

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

Successfully merging a pull request may close this issue.

2 participants