Skip to content

Fallback to py executable on Windows #855

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

Closed
pradyunsg opened this issue Jun 23, 2018 · 11 comments
Closed

Fallback to py executable on Windows #855

pradyunsg opened this issue Jun 23, 2018 · 11 comments

Comments

@pradyunsg
Copy link

Coming from pypa/pip#5526

On Windows, the python.org installers do not add a pythonX.Y.exe file. So, unless the user goes out of their way, it's basically guaranteed that pythonX.Y isn't something on PATH. Thus, on Windows, tox should try to use the py launcher for Windows to run interpreters if it does not find existing pythonX.Y interpreters on PATH. Essentially, pythonX.Y on Unix is equivalent on Windows would be py -X.Y with the advantage of being user configurable.

This would allow tox to operate out-of-the-box on Windows a lot more cases than today, mostly as long as some Python 3.3+ interpreter is installed (there's some cases where py doesn't get added to PATH).

This could essentially take form of tox doing extra work on Windows if pythonX.Y is not on PATH -- the extra work to also try to use py -X.Y.

@pradyunsg
Copy link
Author

Related to #854; that should try using py -X before falling back to pythonX.Y if pythonX is missing on Windows.

@pfmoore
Copy link

pfmoore commented Jun 23, 2018

The pyXY aliases already fall back to py -X.Y. It would make sense to simply add standard py2 and py3 aliases that fell back to py -2/py -3. However, this would require changes to user configurations, so aliasing python2 and python3 might be a more transparent option. I'm not 100% clear why tox chose to have the aliases for pyXY but not for pyX, so I can't really offer a judgement on what's the best approach there.

@pradyunsg
Copy link
Author

pradyunsg commented Jun 23, 2018

I should also note that my Windows knowledge is not complete per se. I have a working knowledge from helping beginners setup their systems for learning and basic scripting. (i.e. I don't use tox on Windows)

@pradyunsg
Copy link
Author

Looking at the code and based on what @pfmoore said, this isn't really a valid issue. tox already falls back to py -X.Y today; the motivating case for this (pythonX) is basically what #854 is for.

@pfmoore
Copy link

pfmoore commented Jun 23, 2018

I'm not sure this should be closed. It would still make sense on Windows to fall pack to py -X.Y when pythonX.Y is specified, and to py -X when pythonX is specified.

Tox currently adds cross-platform aliases pyXY, which are in some sense an alternative approach to falling back, but there's no pyX alias.

@pradyunsg
Copy link
Author

Oh. I misunderstood your last comment. 😅

@pfmoore
Copy link

pfmoore commented Jun 23, 2018

np, it's all a bit confusing :-(

@pfmoore
Copy link

pfmoore commented Jun 23, 2018

I've submitted #856 which requests py2 and py3 aliases.

This issue now becomes simply to make pythonX.Y (and pythonX, or did you intend #854 to cover that separately?) work on Windows, by falling back to py -X.Y in the same way that the aliases do.

It would be a lot less confusing if tox didn't have both pythonX.Y and pyXY`. There may be some difference between the two that I don't understand, but as far as I can see, the documentation isn't at all clear on what it is :-(

@asottile
Copy link
Contributor

I think this is a good idea, if you're looking for prior art pre-commit does this same thing (normalizing PEP394 names to py-launcher names if they're not found):

@pfmoore
Copy link

pfmoore commented Jun 23, 2018

There's been some discussion about a common library to handle this task, as there are a lot of tools that independently reimplement it (tox, nox, pipenv, virtualenv, pre-commit ...) See zooba/pep514tools#2 for some details.

@asottile
Copy link
Contributor

Since this already works for pythonx.x and #855 is essentially asking for it to work for pythonx, going to close this as a duplicate. The PR in #858 should also solve this as well

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants