Tox: windows: py2 / py3 aliases do not resolve to `py -2` / `py -3`

Created on 23 Jun 2018  路  9Comments  路  Source: tox-dev/tox

When trying to write cross-platform tox.ini files it's important to use the pyXY aliases when configuring environments, as these work on Windows and Unix (using pythonX.Y is Unix-only, as the versioned Python executables don't exist on Windows).

But for environments that want to run just with "python 3" and which don't care about the precise version (a common example is running linters, doc builds or similar) there is currently no cross-platform solution.

I propose adding py2 and py3 aliases, similar to the existing py27/py36 ones, which run the corresponding versions of Python (python2 or python3 on Unix, and py -2 or py -3 on Windows).

Supersedes #854 and #855

windows

Most helpful comment

@gaborbernat Yes, that's working now. Thanks to both you and @asottile for fixing this so promptly!

All 9 comments

Agreed this is important, will try to propose and create a solution in the next two weeks.馃憣

Thanks. I'm quite happy to put together a PR myself, but it'll take me longer than that as I'm going to be away. So if you don't get round to it don't worry I can pick it up.

This is already a thing as far as I can tell:

$ tox -e py2 --notest >& /dev/null
$ .tox/py2/bin/python --version
Python 2.7.15rc1
$ tox -e py3 --notest >& /dev/null
$ .tox/py3/bin/python --version
Python 3.6.5

It doesn't work on Windows:

>tox -e py3 --notest
GLOB sdist-make: E:\Work\Scratch\t\setup.py
py3 create: E:\Work\Scratch\t\.tox\py3
ERROR: InterpreterNotFound: python3
___ summary ____
ERROR:   py3: InterpreterNotFound: python3

ah windows, of course.

So the point here is to extend the Windows implementation of tox_get_python_executable to work with python2 and python3. From a quick glance, the regex in https://github.com/tox-dev/tox/blob/master/src/tox/interpreters.py#L146 needs altering, and locate_via_py at https://github.com/tox-dev/tox/blob/master/src/tox/interpreters.py#L164 needs to be amended to take account of the possibility of not getting a minor version number.

As I say, I don't have time right now to put together a full PR, but I believe this is where the changes are needed.

858 is my attempt at this, please try it out on windows (I don't have my python environment set up outside my VM on this laptop yet!)

@pfmoore this went out yesterday so feel free to test it out and let us know if you find any issues.

@gaborbernat Yes, that's working now. Thanks to both you and @asottile for fixing this so promptly!

Was this page helpful?
0 / 5 - 0 ratings