tox-dev / tox-conda

Make tox cooperate with conda envs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash in testenv creation

linus-gates opened this issue · comments

The line:
del venv.envconfig.config.interpreters.name2executable[venv.name]
gives keyError: py38
(py38 is my tox env name).

running on linux, python3.8, inside a conda environment.

Could you describe the context of this issue such that it could be reproduced?

I experience the same error after upgrading to 0.4.1. The code was introduced in #52 I guess.

I use tox-conda in an internal maven based build system. First the environment runs through, but then the error appears

[INFO] [INFO] ___________________________________ summary ____________________________________
[INFO] [INFO]   py36: commands succeeded
[INFO] [INFO]   congratulations :)
[INFO] [ERROR] Traceback (most recent call last):
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/bin/tox", line 8, in <module>
[INFO] [ERROR]     sys.exit(cmdline())
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/session/__init__.py", line 44, in cmdline
[INFO] [ERROR]     main(args)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/session/__init__.py", line 68, in main
[INFO] [ERROR]     exit_code = session.runcommand()
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/session/__init__.py", line 192, in runcommand
[INFO] [ERROR]     return self.subcommand_test()
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/session/__init__.py", line 220, in subcommand_test
[INFO] [ERROR]     run_sequential(self.config, self.venv_dict)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/session/commands/run/sequential.py", line 9, in run_sequential
[INFO] [ERROR]     if venv.setupenv():
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/venv.py", line 594, in setupenv
[INFO] [ERROR]     status = self.update(action=action)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox/venv.py", line 252, in update
[INFO] [ERROR]     self.hook.tox_testenv_create(action=action, venv=self)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
[INFO] [ERROR]     return self._hookexec(self, self.get_hookimpls(), kwargs)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
[INFO] [ERROR]     return self._inner_hookexec(hook, methods, kwargs)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
[INFO] [ERROR]     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
[INFO] [ERROR]     return outcome.get_result()
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
[INFO] [ERROR]     raise ex[1].with_traceback(ex[2])
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
[INFO] [ERROR]     res = hook_impl.function(*args)
[INFO] [ERROR]   File "/home/rbusche/repos/python-maven-plugin/cross/2.12/target/it/ttf/target/pymaven/conda/lib/python3.7/site-packages/tox_conda/plugin.py", line 128, in tox_testenv_create
[INFO] [ERROR]     del venv.envconfig.config.interpreters.name2executable[venv.name]
[INFO] [ERROR] KeyError: 'py36'

My tox.ini looks like this

[tox]
envlist =
    py36

[testenv]
commands =
    pytest \
        -s \
        -m "not plot and not integration" \
        {posargs}
deps =
    pytest >= 3.8,<4

Most details here are probably not so important, but the same tox.ini used to work with 0.2.1. I call tox in my build scripts with something like
tox--installpkg "${cfg.distLocation}*.tar.gz" --workdir ${cfg.tox.workingDirectory} -c ${toxIni.unsafeEncode}.

Maybe this helps in locating the source of the problem. Otherwise we would need to figure out a more minimal reproduction of the problem.

Hi @JarnoRFB,

as @linus-gates mentioned, there is a weak spot that I introduced in a recent commit, but I'd like to understand what is the situation that triggers this bug so we can get the root cause.

Is it reproducible even after deleting your .tox directory?

Hi everyone,

any reason why the commit is not merged yet?
I've tried and it works :)

Hi @domeniconappo,
I was just waiting for an answer before going further with a PR.

Really sorry I didn't get around to testing this, but if it works for other people don't let it get blocked by me.