7

I'm using tox to run tests against different Python interpreters. tox finds my insallations of CPython interpreters as they are in their default locations. However, when I download PyPy for Windows, it is an archive, not an installer. Where should I put PyPy / PyPy3 in order for tox to automatically find them?

Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
  • You should mention, what happens if you try the obvious: put `pypy.exe` into a folder in `%PATH%` – jfs Apr 02 '16 at 16:01
  • @J.F.Sebastian but PyPy3's executable is also `pypy`, so that can't be the solution if I want both. – Amir Rachum Apr 02 '16 at 18:09
  • 1
    It can be if you create `pypy3.bat` that calls the desired pypy executable. Though it might be unnecessary if `tox` uses some heuristic, to find Pypy 3 executable even if it is named `pypy.exe` on Windows. – jfs Apr 02 '16 at 20:18

1 Answers1

0

Like already suggested the way to do this on Windows is to create an executabe batch file acting as a wrapper for the command and making sure it is in PATH.

Since this question was asked the tox documentation, grew a section explaining that in a bit more detail:

Paraphrasing from the tox docs:

Multiple Python versions on Windows

In order to run the unit tests locally all Python versions enlisted in tox.ini need to be installed.

One solution for this is to install the latest conda, and then install all Python versions via conda envs. This will create separate folders for each Python version.

conda create -n python2.7 python=2.7 anaconda

For tox to find them you'll need to:

  • add the main installation version to the systems PATH variable (e.g. D:\Anaconda)
  • for other versions create a BAT scripts into the main installation folder to delegate the call to the correct Python interpreter - e.g. create a file called python2.7.bat containing:

@D:\Anaconda\pkgs\python-2.7.13-1\python.exe %*

This way you can also directly call from cli the matching Python version if you need to(similarly to UNIX systems), for example:

 python2.7 main.py
 python3.6 main.py
Oliver Bestwalter
  • 5,219
  • 33
  • 47