Skip to content

Ignore environment if appropriate runner isn't installed #3504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jabbera opened this issue Mar 22, 2025 · 0 comments
Open

Ignore environment if appropriate runner isn't installed #3504

jabbera opened this issue Mar 22, 2025 · 0 comments
Labels
enhancement help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@jabbera
Copy link

jabbera commented Mar 22, 2025

What's the problem this feature will solve?

I'm trying to make bootstrapping my dev environment as simple as possible. I happen to LOVE tox-uv. I'd like to make it easy for people to get going even if they don't have the plugin installed. Right now, if an environment has a defined runner that is not valid you cannot run any environment at all, even if that environment would run fine with the virtualenv runner.

Describe the solution you'd like

Instead of throwing a KeyError I'd like environments without useable runners to be ignored.

Consider this tox.ini and assume there is an existing uv.lock in the project.

[testenv:dev]
deps=
  tox
  tox-uv
skip_install = true
commands=
    tox -r -e _bootstrap


[testenv:_bootstrap]
runner = uv-venv-lock-runner
envdir = {toxinidir}/.venv
skip_install = true
commands=

If I run:

python3.11 -m venv .tvenv
.tvenv/bin/pip install tox
.tvenv/bin/tox -e dev

I get the error:

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jabbera/temp/tox/.tvenv/lib/python3.11/site-packages/tox/tox_env/register.py", line 72, in runner
    return self._run_envs[name]
           ~~~~~~~~~~~~~~^^^^^^
KeyError: 'uv-venv-lock-runner'

I'm not trying to run that environment to start so the fact that I don't have the runner should not matter. If the environment was ignored I would end up with a properly bootstrapped .venv folder because I install tox-uv into the dev tox environment.

Alternative Solutions

The alternative is fine, but it's certainly not as nice looking:

[testenv:dev]
description = Creates a bootstrapped virtual environment using uv named .venv ready for development on your OS.
deps = 
  uv
  tox
  tox-uv
skip_install = true
commands = 
  tox -e _dev-boostrap


[testenv:_dev-boostrap]
description = This is what actually creates the environment. Should only be called from the dev environment. It exsts so tox -r -e dev works.
envdir = {toxinidir}/.venv
skip_install = true
deps = 
commands = 
  uv sync --extra dev
@jabbera jabbera changed the title Ignore environment if appropriate running isn't installed Ignore environment if appropriate runner isn't installed Mar 22, 2025
@gaborbernat gaborbernat added the help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. label Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

2 participants