From 6944f07c5eeb4fff85a1f231f572974b70b258c3 Mon Sep 17 00:00:00 2001 From: Ethan Rooke Date: Tue, 14 Oct 2025 20:20:13 -0500 Subject: [PATCH 1/4] switch from uv run python to sys.executable To ensure that the same python interpreter is used to spawn pytask as is running the test we currently rely on `uv` to spawn the instance of python. This relies on us having spawned the test process from `uv` in the first place and requires that `uv` be used by anyone attempting to test the software. This switches the pattern `uv run python` to call (`sys.executable`)[https://docs.python.org/3/library/sys.html#sys.executable] which gives the absolute path of the interpreter being used. --- tests/test_capture.py | 6 +++--- tests/test_config.py | 2 +- tests/test_dag_command.py | 2 +- tests/test_execute.py | 6 +++--- tests/test_hook_module.py | 10 +++------- tests/test_task.py | 2 +- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/test_capture.py b/tests/test_capture.py index ba37be8b..a48c3ca3 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -87,7 +87,7 @@ def task_show_capture(): """ tmp_path.joinpath("workflow.py").write_text(textwrap.dedent(source)) - result = run_in_subprocess(("uv", "run", "python", "workflow.py"), cwd=tmp_path) + result = run_in_subprocess((sys.executable, "workflow.py"), cwd=tmp_path) assert result.exit_code == ExitCode.FAILED @@ -128,7 +128,7 @@ def test_wrong_capture_method(tmp_path): """ tmp_path.joinpath("workflow.py").write_text(textwrap.dedent(source)) - result = run_in_subprocess(("uv", "run", "python", "workflow.py"), cwd=tmp_path) + result = run_in_subprocess((sys.executable, "workflow.py"), cwd=tmp_path) assert result.exit_code == ExitCode.CONFIGURATION_FAILED assert "Value 'a' is not a valid" in result.stdout assert "Traceback" not in result.stdout @@ -255,7 +255,7 @@ def task_unicode(): tmp_path.joinpath("workflow.py").write_text( textwrap.dedent(source), encoding="utf-8" ) - result = run_in_subprocess(("uv", "run", "python", "workflow.py"), cwd=tmp_path) + result = run_in_subprocess((sys.executable, "workflow.py"), cwd=tmp_path) assert result.exit_code == ExitCode.OK assert "1 Succeeded" in result.stdout diff --git a/tests/test_config.py b/tests/test_config.py index c46f5edb..418780ff 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -114,7 +114,7 @@ def test_paths_are_relative_to_configuration_file(tmp_path): session = build(paths=[Path("src")]) """ tmp_path.joinpath("script.py").write_text(textwrap.dedent(source)) - result = run_in_subprocess(("uv", "run", "python", "script.py"), cwd=tmp_path) + result = run_in_subprocess((sys.executable, "script.py"), cwd=tmp_path) assert result.exit_code == ExitCode.OK assert "1 Succeeded" in result.stdout diff --git a/tests/test_dag_command.py b/tests/test_dag_command.py index 3ca41baf..d56927fc 100644 --- a/tests/test_dag_command.py +++ b/tests/test_dag_command.py @@ -92,7 +92,7 @@ def main(): tmp_path.joinpath("input.txt").touch() result = subprocess.run( - ("uv", "run", "python", "task_example.py"), + (sys.executable, "task_example.py"), cwd=tmp_path, check=True, capture_output=True, diff --git a/tests/test_execute.py b/tests/test_execute.py index 1a233160..93b84cd9 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -26,7 +26,7 @@ def test_python_m_pytask(tmp_path): tmp_path.joinpath("task_module.py").write_text("def task_example(): pass") result = run_in_subprocess( - ("uv", "run", "python", "-m", "pytask", tmp_path.as_posix()) + (sys.executable, "-m", "pytask", tmp_path.as_posix()) ) assert result.exit_code == ExitCode.OK @@ -602,7 +602,7 @@ def create_file( """ tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source)) result = subprocess.run( - ("uv", "run", "python", tmp_path.joinpath("task_module.py").as_posix()), + (sys.executable, tmp_path.joinpath("task_module.py").as_posix()), check=False, ) assert result.returncode == ExitCode.OK @@ -632,7 +632,7 @@ def task2() -> None: pass """ tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source)) result = run_in_subprocess( - ("uv", "run", "python", tmp_path.joinpath("task_module.py").as_posix()) + (sys.executable, tmp_path.joinpath("task_module.py").as_posix()) ) assert result.exit_code == ExitCode.OK diff --git a/tests/test_hook_module.py b/tests/test_hook_module.py index eba48680..5aea29ff 100644 --- a/tests/test_hook_module.py +++ b/tests/test_hook_module.py @@ -1,6 +1,7 @@ from __future__ import annotations import subprocess +import sys import textwrap import pytest @@ -25,9 +26,7 @@ def pytask_extend_command_line_interface(cli): if module_name: args = ( - "uv", - "run", - "python", + sys.executable, "-m", "pytask", "build", @@ -70,10 +69,7 @@ def pytask_extend_command_line_interface(cli): if module_name: args = ( - "uv", - "run", - "--no-project", - "python", + sys.executable, "-m", "pytask", "build", diff --git a/tests/test_task.py b/tests/test_task.py index a2f70ad7..d7294b47 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -667,7 +667,7 @@ def task_second(): tmp_path.joinpath("task_example.py").write_text(textwrap.dedent(source)) result = subprocess.run( - ("uv", "run", "python", "task_example.py"), + (sys.executable, "task_example.py"), cwd=tmp_path, capture_output=True, check=False, From af7a9587b76e7efdc93f20333ad5126a9d8176a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 01:29:18 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_execute.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_execute.py b/tests/test_execute.py index 93b84cd9..809d0c7e 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -25,9 +25,7 @@ def test_python_m_pytask(tmp_path): tmp_path.joinpath("task_module.py").write_text("def task_example(): pass") - result = run_in_subprocess( - (sys.executable, "-m", "pytask", tmp_path.as_posix()) - ) + result = run_in_subprocess((sys.executable, "-m", "pytask", tmp_path.as_posix())) assert result.exit_code == ExitCode.OK From 35924dede9a59b7a9cf3788509824c0384468d6a Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 17 Oct 2025 00:54:24 +0200 Subject: [PATCH 3/4] Remove last occurences of uv. --- tests/test_hook_module.py | 51 ++++++++++++--------------------------- tests/test_warnings.py | 3 ++- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/tests/test_hook_module.py b/tests/test_hook_module.py index 5aea29ff..4b5a75cc 100644 --- a/tests/test_hook_module.py +++ b/tests/test_hook_module.py @@ -10,8 +10,8 @@ from tests.conftest import run_in_subprocess -@pytest.mark.parametrize("module_name", [True, False]) -def test_add_new_hook_via_cli(tmp_path, module_name): +@pytest.mark.parametrize("hook_location", ["hooks/hooks.py", "hooks.hooks"]) +def test_add_new_hook_via_cli(tmp_path, hook_location): hooks = """ import click from pytask import hookimpl @@ -24,36 +24,24 @@ def pytask_extend_command_line_interface(cli): tmp_path.joinpath("hooks").mkdir() tmp_path.joinpath("hooks", "hooks.py").write_text(textwrap.dedent(hooks)) - if module_name: - args = ( - sys.executable, - "-m", - "pytask", - "build", - "--hook-module", - "hooks.hooks", - "--help", - ) - else: - args = ( - "uv", - "run", - "pytask", - "build", - "--hook-module", - "hooks/hooks.py", - "--help", - ) - + args = ( + sys.executable, + "-m", + "pytask", + "build", + "--hook-module", + hook_location, + "--help", + ) result = run_in_subprocess(args, cwd=tmp_path) assert result.exit_code == ExitCode.OK assert "--new-option" in result.stdout -@pytest.mark.parametrize("module_name", [True, False]) -def test_add_new_hook_via_config(tmp_path, module_name): +@pytest.mark.parametrize("hook_location", ["hooks/hooks.py", "hooks.hooks"]) +def test_add_new_hook_via_config(tmp_path, hook_location): tmp_path.joinpath("pyproject.toml").write_text( - "[tool.pytask.ini_options]\nhook_module = ['hooks/hooks.py']" + f"[tool.pytask.ini_options]\nhook_module = ['{hook_location}']" ) hooks = """ @@ -67,16 +55,7 @@ def pytask_extend_command_line_interface(cli): tmp_path.joinpath("hooks").mkdir() tmp_path.joinpath("hooks", "hooks.py").write_text(textwrap.dedent(hooks)) - if module_name: - args = ( - sys.executable, - "-m", - "pytask", - "build", - "--help", - ) - else: - args = ("uv", "run", "--no-project", "pytask", "build", "--help") + args = (sys.executable, "-m", "pytask", "build", "--help") result = run_in_subprocess(args, cwd=tmp_path) assert result.exit_code == ExitCode.OK diff --git a/tests/test_warnings.py b/tests/test_warnings.py index 88110187..6e551507 100644 --- a/tests/test_warnings.py +++ b/tests/test_warnings.py @@ -1,5 +1,6 @@ from __future__ import annotations +import sys import textwrap import pytest @@ -148,7 +149,7 @@ def warn_now(): path_to_warn_module.write_text(textwrap.dedent(warn_module)) # Cannot use runner since then warnings are not ignored by default. - result = run_in_subprocess(("uv", "run", "pytask"), cwd=tmp_path) + result = run_in_subprocess((sys.executable, "-m", "pytask"), cwd=tmp_path) assert result.exit_code == ExitCode.OK assert "Warnings" not in result.stdout assert "warning!!!" not in result.stdout From c44ab712e34746e2b8579fa945591c6740dbe567 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 17 Oct 2025 00:55:53 +0200 Subject: [PATCH 4/4] Add to changes.2 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13dd200c..c54af609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and - {pull}`707` drops support for Python 3.9 as it has reached end of life. - {pull}`708` updates mypy and fixes type issues. - {pull}`709` add uv pre-commit check. +- {pull}`713` removes uv as a test dependency. Closes {issue}`712`. Thanks to {user}`erooke`! ## 0.5.5 - 2025-07-25