How do I map the pyenv to tox if I use tox in poetry #4044
Replies: 1 comment
|
For the normal test matrix, name the environments by the Python factor: [tool.tox]
env_list = ["py311", "py312", "coverage-report"]
[tool.tox.env_run_base]
package = "editable"
deps = ["coverage[toml]", "unittest-xml-reporting", "python-dotenv"]
commands = [
["coverage", "run", "--data-file=.coverage.{envname}"],
]
[tool.tox.env.coverage-report]
depends = ["py311", "py312"]
skip_install = true
deps = ["coverage[toml]", "unittest-xml-reporting"]
commands = [
["coverage", "combine"],
["coverage", "xml", "-o", "coverage.xml"],
]Then make those interpreters visible to the process running tox. With pyenv that means having the relevant versions installed and selected so its shims can resolve On current tox, interpreter resolution starts with the Python factor in the environment name ( One other mismatch in the example: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
My setup is
pyproject.tom
`
[tool.tox]
env_list = ["3.11.16", "3.12.14", "coverage-report"] # We have to specify the python versions explicitly to get around acivating multiple versions in the shim.
[tool.tox.env_run_base]
pass_env = ["*"]
package = "editable"
deps = ["coverage[toml]", "unittest-xml-reporting", "python-dotenv"]
commands = [
["coverage", "run", "--data-file=.coverage.{envname}"],
]
[tool.tox.env.coverage-report]
depends = ["3.11.15", "3.12.13"]
skip_install = true
pass_env = ["*"]
deps = ["coverage[toml]", "unittest-xml-reporting"]
commands = [
["coverage", "combine"],
["coverage", "xml", "-o", "coverage.xml"]
]
`
and a Makefile
`
PYTHON_VERSION := $(shell cat .python-version)
PYENV_VERSIONS := 3.14.7 3.12.14 3.11.16 3.9.25
all: setup_environment
clean:
poetry run pre-commit uninstall
git clean -fdX
setup_environment: check
pyenv install $(PYENV_VERSIONS) --skip-existing
&& pyenv global $(PYENV_VERSIONS)
&& poetry env use $(PYTHON_VERSION)
&& poetry install
&& poetry run pre-commit install
check: pyenv_exists poetry_exists is_git
pyenv_exists: ; @which pyenv > /dev/null
poetry_exists: ; @which poetry > /dev/null
is_git: ; @git rev-parse --git-dir > /dev/null
`
It seems that py311,py312 in env_list does not work, tox cant find the python interpreter, falls back to the default interpreter and does not choose the expected python version. What do I do wrong?
All reactions