Skip to content

Labeled environments cannot use runners from provisioned plugins #2916

@masenf

Description

@masenf

Issue

When a tox environment has a runner derived from a plugin that is named in the requires key, the environment cannot appear in a top-level label expression.

See minimal reproducer: https://github.com/masenf/tox-label-provision-plugin-runner

[tox]
requires = foo-runner
labels =
    foo = bar, baz
envlist = bar, baz

[testenv:{bar,baz}]
runner = foo

running tox uses the envlist, which works fine.

running tox -m foo uses the label foo, and blows up before passing off control to the provisioned tox

Environment

Provide at least:

  • OS: ubuntu 20.04
  • pip list of the host Python where tox is installed:
cachetools==5.3.0
chardet==5.1.0
colorama==0.4.6
distlib==0.3.6
filelock==3.9.0
packaging==23.0
platformdirs==3.0.0
pluggy==1.0.0
pyproject-api==1.5.0
tomli==2.0.1
tox==4.4.4
virtualenv==20.19.0

Output of running tox

Provide the output of tox -rvv:

tox -rvv -m foo
ROOT: 1297 W will run in automatically provisioned tox, host /home/mfurer/.pytools/bin/python is missing [requires (has)]: foo-runner [tox/provision.py:125]
Traceback (most recent call last):
  File "/home/mfurer/.pytools/bin/tox", line 8, in <module>
    sys.exit(run())
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/run.py", line 19, in run
    result = main(sys.argv[1:] if args is None else args)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/run.py", line 41, in main
    result = provision(state)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/provision.py", line 126, in provision
    return run_provision(provision_tox_env, state)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/provision.py", line 144, in run_provision
    tox_env: PythonRun = cast(PythonRun, state.envs[name])
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/session/env_select.py", line 337, in __getitem__
    return self._defined_envs[item].env
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/session/env_select.py", line 233, in _defined_envs
    self._mark_active()
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/session/env_select.py", line 321, in _mark_active
    self._defined_envs_[env_name].is_active = True
KeyError: 'bar'

Minimal example

https://github.com/masenf/tox-label-provision-plugin-runner

Metadata

Metadata

Assignees

Labels

bug:minordoes not affect many people or has no big impacthelp:wantedIssues that have been acknowledged, a solution determined and a PR might likely be accepted.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions