Skip to content

Can't set uv_python_preference only for a certain environment factor #260

@bluetech

Description

@bluetech

Issue

I want to set uv_python_preference = onlymanaged when the environment contains an onlymanaged factor, and leave it default otherwise. So I wrote this:

[testenv]
uv_python_preference =
    onlymanaged: only-managed

Now it works for e.g. tox -e py313-onlymanaged, and correctly passes -p only-managed to uv venv. But it doesn't work without the factor, e.g. tox -e py313. It tries to run -p None which fails:

$ tox -e py313
py313: venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.13 --allow-existing --python-preference None /home/ran/src/pytest/.tox/py313
py313: skipped because could not find python interpreter with spec(s): cpython3.13

Such a setup works with e.g. uv_resolution so I think my tox syntax is right.

Environment

Provide at least:

  • OS: Linux
Output of pip list of the host Python, where tox is installed
Package       Version
------------- -------
cachetools    6.2.1
chardet       5.2.0
colorama      0.4.6
distlib       0.4.0
filelock      3.20.0
packaging     25.0
platformdirs  4.5.0
pluggy        1.6.0
pyproject-api 1.10.0
tox           4.31.0
tox-uv        1.29.0
uv            0.9.5
virtualenv    20.35.3

Output of running tox

Output of tox -rvv
linting: 109 W remove tox env folder /home/ran/src/pytest/.tox/linting [tox/tox_env/api.py:360]
linting: 118 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/linting [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
linting: 123 W skipped because could not find python interpreter with spec(s): cpython3 [tox/session/cmd/run/single.py:50]
linting: SKIP ⚠ in 0.01 seconds
.pkg: 124 W remove tox env folder /home/ran/src/pytest/.tox/.pkg [tox/tox_env/api.py:360]
py310: 134 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310: 139 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310: SKIP ⚠ in 0.02 seconds
py311: 142 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.11 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py311 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py311: 147 W skipped because could not find python interpreter with spec(s): cpython3.11 [tox/session/cmd/run/single.py:50]
py311: SKIP ⚠ in 0.01 seconds
py312: 150 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.12 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py312 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py312: 155 W skipped because could not find python interpreter with spec(s): cpython3.12 [tox/session/cmd/run/single.py:50]
py313: 156 W remove tox env folder /home/ran/src/pytest/.tox/py313 [tox/tox_env/api.py:360]
py312: SKIP ⚠ in 0.01 seconds
py313: 159 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.13 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py313 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py313: 164 W skipped because could not find python interpreter with spec(s): cpython3.13 [tox/session/cmd/run/single.py:50]
py313: SKIP ⚠ in 0.01 seconds
py314: 167 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p /home/ran/.local/share/uv/tools/tox/bin/python --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py314 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py314: 172 W skipped because could not find python interpreter with spec(s): /home/ran/.local/share/uv/tools/tox/bin/python [tox/session/cmd/run/single.py:50]
py314: SKIP ⚠ in 0.01 seconds
pypy3: 175 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p pypy3 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/pypy3 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
pypy3: 179 W skipped because could not find python interpreter with spec(s): pypy3 [tox/session/cmd/run/single.py:50]
pypy3: SKIP ⚠ in 0.01 seconds
py310-pexpect: 182 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-pexpect [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-pexpect: 186 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-pexpect: SKIP ⚠ in 0.01 seconds
py310-xdist: 189 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-xdist [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-xdist: 194 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-xdist: SKIP ⚠ in 0.01 seconds
py310-twisted24: 196 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-twisted24 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-twisted24: 200 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-twisted24: SKIP ⚠ in 0.01 seconds
py310-twisted25: 203 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-twisted25 [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-twisted25: 207 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-twisted25: SKIP ⚠ in 0.01 seconds
py310-asynctest: 210 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-asynctest [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-asynctest: 215 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-asynctest: SKIP ⚠ in 0.01 seconds
py310-numpy: 218 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-numpy [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-numpy: 222 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-numpy: SKIP ⚠ in 0.01 seconds
py310-pluggymain: 225 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-pluggymain [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-pluggymain: 229 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-pluggymain: SKIP ⚠ in 0.01 seconds
py310-pylib: 231 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-pylib [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-pylib: 236 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
py310-pylib: SKIP ⚠ in 0.01 seconds
doctesting: 239 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p /home/ran/.local/share/uv/tools/tox/bin/python --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/doctesting [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
doctesting: 243 W skipped because could not find python interpreter with spec(s): /home/ran/.local/share/uv/tools/tox/bin/python [tox/session/cmd/run/single.py:50]
doctesting: SKIP ⚠ in 0.01 seconds
doctesting-coverage: 246 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p /home/ran/.local/share/uv/tools/tox/bin/python --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/doctesting-coverage [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
doctesting-coverage: 250 W skipped because could not find python interpreter with spec(s): /home/ran/.local/share/uv/tools/tox/bin/python [tox/session/cmd/run/single.py:50]
doctesting-coverage: SKIP ⚠ in 0.01 seconds
plugins: 252 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p /home/ran/.local/share/uv/tools/tox/bin/python --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/plugins [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
plugins: 256 W skipped because could not find python interpreter with spec(s): /home/ran/.local/share/uv/tools/tox/bin/python [tox/session/cmd/run/single.py:50]
plugins: SKIP ⚠ in 0.01 seconds
py310-freeze: 259 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.10 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py310-freeze [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py310-freeze: 263 W skipped because could not find python interpreter with spec(s): cpython3.10 [tox/session/cmd/run/single.py:50]
docs: 263 W remove tox env folder /home/ran/src/pytest/.tox/docs [tox/tox_env/api.py:360]
py310-freeze: SKIP ⚠ in 0.01 seconds
docs: 311 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.12 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/docs [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
docs: 315 W skipped because could not find python interpreter with spec(s): cpython3.12 [tox/session/cmd/run/single.py:50]
docs: SKIP ⚠ in 0.05 seconds
docs-checklinks: 317 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/docs-checklinks [tox/tox_env/api.py:464]
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
docs-checklinks: 321 W skipped because could not find python interpreter with spec(s): cpython3 [tox/session/cmd/run/single.py:50]
py311-exceptiongroup: 322 W venv> /home/ran/.local/share/uv/tools/tox/bin/uv venv -p cpython3.11 --allow-existing -v --python-preference None /home/ran/src/pytest/.tox/py311-exceptiongroup [tox/tox_env/api.py:464]
docs-checklinks: SKIP ⚠ in 0.01 seconds
error: invalid value 'None' for '--python-preference <PYTHON_PREFERENCE>'
  [possible values: only-managed, managed, system, only-system]

For more information, try '--help'.
py311-exceptiongroup: 327 W skipped because could not find python interpreter with spec(s): cpython3.11 [tox/session/cmd/run/single.py:50]
  linting: SKIP (0.01 seconds)
  py310: SKIP (0.02 seconds)
  py311: SKIP (0.01 seconds)
  py312: SKIP (0.01 seconds)
  py313: SKIP (0.01 seconds)
  py314: SKIP (0.01 seconds)
  pypy3: SKIP (0.01 seconds)
  py310-pexpect: SKIP (0.01 seconds)
  py310-xdist: SKIP (0.01 seconds)
  py310-twisted24: SKIP (0.01 seconds)
  py310-twisted25: SKIP (0.01 seconds)
  py310-asynctest: SKIP (0.01 seconds)
  py310-numpy: SKIP (0.01 seconds)
  py310-pluggymain: SKIP (0.01 seconds)
  py310-pylib: SKIP (0.01 seconds)
  doctesting: SKIP (0.01 seconds)
  doctesting-coverage: SKIP (0.01 seconds)
  plugins: SKIP (0.01 seconds)
  py310-freeze: SKIP (0.01 seconds)
  docs: SKIP (0.05 seconds)
  docs-checklinks: SKIP (0.01 seconds)
  py311-exceptiongroup: SKIP (0.01 seconds)
  evaluation failed :( (0.25 seconds)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions