tox-dev / tox-uv

Use https://github.com/astral-sh/uv with tox
MIT License
136 stars 19 forks source link

native toml config ignores the `deps` parameter #120

Closed azmeuk closed 3 weeks ago

azmeuk commented 3 weeks ago

Issue

With this native toml tox configuration, I get an error indicating that pre-commit has not been installed:

[tool.tox.env.style]
skip_install = true
deps = ["pre-commit-uv"]
commands = [
    ["pre-commit", "run", "--all-files", "--show-diff-on-failure"],
]

Environment

Provide at least:

Output of pip list of the host Python, where tox is installed ```console Using Python 3.12.7 environment at /home/eloi/dev/yaal/scim2-tester/.venv Package Version Editable project location ----------------- ----------- -------------------------------- annotated-types 0.7.0 anyio 4.6.2.post1 cachetools 5.5.0 certifi 2024.8.30 chardet 5.2.0 colorama 0.4.6 coverage 7.6.4 distlib 0.3.9 dnspython 2.7.0 email-validator 2.2.0 filelock 3.16.1 h11 0.14.0 httpcore 1.0.6 httpx 0.27.2 idna 3.10 iniconfig 2.0.0 markupsafe 3.0.2 packaging 24.1 platformdirs 4.3.6 pluggy 1.5.0 pydantic 2.9.2 pydantic-core 2.23.4 pyproject-api 1.8.0 pytest 8.3.3 pytest-cov 6.0.0 pytest-cover 3.0.0 pytest-coverage 0.0 pytest-httpserver 1.1.0 scim2-client 0.2.0 scim2-models 0.2.2 scim2-tester 0.1.5 /home/eloi/dev/yaal/scim2-tester sniffio 1.3.1 tox 4.23.2 tox-uv 1.16.0 typing-extensions 4.12.2 uv 0.4.29 virtualenv 20.27.1 werkzeug 3.1.0 ```

Output of running tox

Output of tox -rvv ```console ❯ tox -rvv -e style style: 176 W remove tox env folder /home/eloi/dev/yaal/scim2-models/.tox/style [tox/tox_env/api.py:325] style: 183 W venv> /home/eloi/dev/yaal/scim2-tester/.venv/bin/uv venv -p /home/eloi/dev/yaal/scim2-tester/.venv/bin/python --allow-existing -v /home/eloi/dev/yaal/scim2-models/.tox/style [tox/tox_env/api.py:427] DEBUG uv 0.4.29 DEBUG Found project root: `/home/eloi/dev/yaal/scim2-models` DEBUG No workspace root found, using project root DEBUG Checking for Python interpreter at path `/home/eloi/dev/yaal/scim2-tester/.venv/bin/python` Using CPython 3.12.7 interpreter at: /home/eloi/dev/yaal/scim2-tester/.venv/bin/python Creating virtual environment at: .tox/style DEBUG Allowing existing directory style: 192 I exit 0 (0.01 seconds) /home/eloi/dev/yaal/scim2-models> /home/eloi/dev/yaal/scim2-tester/.venv/bin/uv venv -p /home/eloi/dev/yaal/scim2-tester/.venv/bin/python --allow-existing -v /home/eloi/dev/yaal/scim2-models/.tox/style pid=421408 [tox/execute/api.py:286] style: 193 W uv-sync> uv sync --frozen --no-dev -v [tox/tox_env/api.py:427] DEBUG uv 0.4.29 DEBUG Found project root: `/home/eloi/dev/yaal/scim2-models` DEBUG No workspace root found, using project root DEBUG The virtual environment's Python version satisfies `Python >=3.9` DEBUG Using request timeout of 30s DEBUG Requirement already cached: annotated-types==0.7.0 DEBUG Requirement already cached: dnspython==2.7.0 DEBUG Requirement already cached: email-validator==2.2.0 DEBUG Requirement already cached: idna==3.10 DEBUG Requirement already cached: pydantic==2.9.2 DEBUG Requirement already cached: pydantic-core==2.23.4 DEBUG Directory source requirement already cached: scim2-models==0.2.2 (from file:///home/eloi/dev/yaal/scim2-models) DEBUG Requirement already cached: typing-extensions==4.12.2 Installed 8 packages in 2ms + annotated-types==0.7.0 + dnspython==2.7.0 + email-validator==2.2.0 + idna==3.10 + pydantic==2.9.2 + pydantic-core==2.23.4 + scim2-models==0.2.2 (from file:///home/eloi/dev/yaal/scim2-models) + typing-extensions==4.12.2 style: 210 I exit 0 (0.02 seconds) /home/eloi/dev/yaal/scim2-models> uv sync --frozen --no-dev -v pid=421426 [tox/execute/api.py:286] style: 210 W commands[0]> pre-commit run --all-files --show-diff-on-failure [tox/tox_env/api.py:427] style: 211 E failed with pre-commit is not allowed, use allowlist_externals to allow it [tox/session/cmd/run/single.py:57] style: FAIL code 1 (0.03 seconds) evaluation failed :( (0.09 seconds) ```
azmeuk commented 3 weeks ago

Nevermind, I had set the default runner to "uv-venv-lock-runner". My issue is fixed with this configuration:

[tool.tox.env.style]
skip_install = true
runner = "uv-venv-runner"
deps = ["pre-commit-uv"]
commands = [
    ["pre-commit", "run", "--all-files", "--show-diff-on-failure"],
]
gaborbernat commented 3 weeks ago

Note that with the introduction of the dependency groups, you no longer need to use deps here and you can just put your dependencies inside the dependency group, your pryproject.toml file.