Skip to content

Instantly share code, notes, and snippets.

@oleksis
Last active January 2, 2023 05:12
Show Gist options
  • Save oleksis/87b5726e73e62f3e5c8cfb585d7fe4e9 to your computer and use it in GitHub Desktop.
Save oleksis/87b5726e73e62f3e5c8cfb585d7fe4e9 to your computer and use it in GitHub Desktop.

How to configure Tox and Pyenv

Tox

INI configuration

[tox]
envlist = py37, py38, py39, py310, py311

[testenv]
commands =
    python -c "import sys; print( 'Python', '.'.join(str(v) for v in sys.version_info[:3]), sys.executable)"

Pyenv

➜ pyenv install 3.7.9 3.8.10 3.9.13 3.10.9 3.11.1
➜ pyenv versions
  3.10.9
  3.11.1
  3.7.9
  3.8.10
  3.9.13

➜ pyenv local 3.7.9 3.8.10 3.9.13 3.10.9 3.11.1
➜ python -c "import sys; print(sys.executable)"
~\.pyenv\pyenv-win\versions\3.7.9\python.exe

➜ pyenv global 3.10.9
➜ python -m pip install -U tox
➜ python -m tox
py37: commands[0]> python -c "import sys; print( 'Python', '.'.join(str(v) for v in sys.version_info[:3]), sys.executable)"
Python 3.7.9 ~\.tox\py37\Scripts\python.EXE
py37: OK ✔ in 3.7 seconds
py38: commands[0]> python -c "import sys; print( 'Python', '.'.join(str(v) for v in sys.version_info[:3]), sys.executable)"
Python 3.8.10 ~\.tox\py38\Scripts\python.EXE
py38: OK ✔ in 4.48 seconds
py39: commands[0]> python -c "import sys; print( 'Python', '.'.join(str(v) for v in sys.version_info[:3]), sys.executable)"
Python 3.9.13 ~\.tox\py39\Scripts\python.EXE
py39: OK ✔ in 5.16 seconds
py310: commands[0]> python -c "import sys; print( 'Python', '.'.join(str(v) for v in sys.version_info[:3]), sys.executable)"
Python 3.10.9 ~\.tox\py310\Scripts\python.EXE
py310: OK ✔ in 4.28 seconds
py311: commands[0]> python -c "import sys; print( 'Python', '.'.join(str(v) for v in sys.version_info[:3]), sys.executable)"
Python 3.11.1 ~\.tox\py311\Scripts\python.EXE
  py37: OK (3.70=setup[3.34]+cmd[0.36] seconds)
  py38: OK (4.48=setup[4.05]+cmd[0.44] seconds)
  py39: OK (5.16=setup[4.75]+cmd[0.41] seconds)
  py310: OK (4.28=setup[3.89]+cmd[0.39] seconds)
  py311: OK (4.27=setup[3.92]+cmd[0.34] seconds)
  congratulations :) (22.39 seconds)

Note Using pyenv in WSL2 add the Interop settings

sudo vim /etc/wsl.conf
[boot]
systemd=true

[interop]
appendWindowsPath=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment