Search code examples
pythontox

How to get tox to use a Python interpreter on a specifc path


I'm using tox version 4.12.0, and have env_list = py{3.8,3.9}-pytest5. This successfully finds and uses the OS-supplied Python 3.9 to run those tests, but skips testing with Python 3.8 because it can't find an interpreter. (This is correct behaviour so far: I have no Python 3.8 interpreter in my path and do not want one in my path.)

So I'd like to get tox to use a Python interpreter on a specifc path, in this case one compiled with pythonz: /home/cjs/.pythonz/pythons/CPython-3.8.18/bin/python3. However, when I add a base_python setting for this:

base_python =
    py3.8: /home/cjs/.pythonz/pythons/CPython-3.8.18/bin/python3

It gives me the following complaint:

py3.8-pytest5: failed with env name py3.8-pytest5 conflicting with base python /home/cjs/.pythonz/pythons/CPython-3.8.18/bin/python3

I get the same complaint even if I change the executable name at the end of the path to python3.8 (which also exists in that directory). I've looked at the documentation for ignore_python_base_conflict, which I don't really understand, and tried both true and false settings of that variable, but it seems to make no difference.

How do I tell tox to use a specific Python interpreter on a specific path for a particular test?

Bonus points if you can tell me how to easily set this path at runtime, since for other users it's obviously not going to be under /home/cjs/....


Solution

  • This has been confirmed to be a bug in tox; it should accept a full path to a Python interpreter and use it.