Trouble with poetry, pyenv and tox #11035
Replies: 1 comment
|
Poetry only selects the interpreter for Poetry's own project environment; tox still has to discover a separate executable for each py311 and py312 environment. With pyenv, first make both versions visible to the same shell that launches tox: run pyenv local 3.11.x 3.12.x, pyenv rehash, and verify that python3.11 --version and python3.12 --version both resolve before running poetry run tox. If those names do not resolve, inspect pyenv versions and pyenv which python3.11/python3.12; the issue is the shim PATH rather than Poetry. You can also make the intent explicit with a base_python entry under tool.tox.env.py311 and tool.tox.env.py312. One other issue in the sample is that coverage run only receives --data-file and no module, script, or command, so after interpreter discovery is fixed that command will still need a target such as coverage run --data-file=.coverage.{envname} -m pytest. Running tox directly from the pyenv-enabled shell is usually simpler than nesting it inside Poetry, because tox already creates and manages the test environments. |
Uh oh!
There was an error while loading. Please reload this page.
I use pyenv to maintain my python environements and poetry to maintain my project within it. Tox is used to test my package in different environements. At the moment tox cant find any environement and I cant figure out why. Does anybody have an idea how?
#Makefile setup_environment: check pyenv install $(PYTHON_VERSIONS) --skip-existing \ && pyenv local $(PYTHON_VERSIONS) \ && poetry env use $(PYTHON_VERSION) \ && poetry install \ && poetry run pre-commit install`#pyprojetct.toml
[tool.tox]
env_list = ["py311", "py312", "coverage-report"] # We have to specify the python versions explicitly to get around acivating multiple versions in the shim.
isolated_build = true
[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 = ["py311", "py312"]
skip_install = true
pass_env = ["*"]
deps = ["coverage[toml]", "unittest-xml-reporting"]
commands = [
["coverage", "combine"],
["coverage", "xml", "-o", "coverage.xml"]
]
`
All reactions