diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d740fab..b115803 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,6 @@ repos: rev: "2.1.3" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.15"] - repo: https://github.com/astral-sh/ruff-pre-commit rev: "v0.4.9" hooks: diff --git a/src/tox_uv/_venv.py b/src/tox_uv/_venv.py index 204bb2a..d2fcf80 100644 --- a/src/tox_uv/_venv.py +++ b/src/tox_uv/_venv.py @@ -111,6 +111,7 @@ def venv_dir(self) -> Path: @property def environment_variables(self) -> dict[str, str]: env = super().environment_variables + env.pop("UV_PYTHON", None) # UV_PYTHON takes precedence over VIRTUAL_ENV env["VIRTUAL_ENV"] = str(self.venv_dir) return env diff --git a/tests/test_tox_uv_venv.py b/tests/test_tox_uv_venv.py index e16ba25..31e3d7a 100644 --- a/tests/test_tox_uv_venv.py +++ b/tests/test_tox_uv_venv.py @@ -11,6 +11,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: + import pytest from tox.pytest import ToxProjectCreator @@ -142,3 +143,12 @@ def test_uv_env_python_not_in_path(tox_project: ToxProjectCreator) -> None: tox_ini = project.path / "tox.ini" assert tox_ini.is_file() subprocess.check_call([sys.executable, "-m", "tox", "-c", tox_ini], env=env) + + +def test_uv_python_set(tox_project: ToxProjectCreator, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("UV_PYTHON", sys.executable) + project = tox_project({ + "tox.ini": "[testenv]\npackage=skip\ndeps=setuptools\ncommands=python -c 'import setuptools'" + }) + result = project.run("-vv") + result.assert_success()