Skip to content

Commit 619796b

Browse files
authored
Do not install dev dependencies by default (#95)
1 parent fcde8fe commit 619796b

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/tox_uv/_run_lock.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,21 @@ def _build_packages(self) -> list[Package]:
3939
def register_config(self) -> None:
4040
super().register_config()
4141
add_extras_to_env(self.conf)
42+
self.conf.add_config(
43+
keys=["with_dev"],
44+
of_type=bool,
45+
default=False,
46+
desc="Install dev dependencies or not",
47+
)
4248
add_skip_missing_interpreters_to_core(self.core, self.options)
4349

4450
def _setup_env(self) -> None:
4551
super()._setup_env()
4652
cmd = ["uv", "sync", "--frozen"]
4753
for extra in cast(Set[str], sorted(self.conf["extras"])):
4854
cmd.extend(("--extra", extra))
55+
if not self.conf["with_dev"]:
56+
cmd.append("--no-dev")
4957
outcome = self.execute(cmd, stdin=StdinSource.OFF, run_id="uv-sync", show=False)
5058
outcome.assert_success()
5159

tests/test_tox_uv_lock.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_uv_lock_list_dependencies_command(tox_project: ToxProjectCreator) -> No
3232
"venv",
3333
[uv, "venv", "-p", sys.executable, "--allow-existing", "-v", str(project.path / ".tox" / "py")],
3434
),
35-
("py", "uv-sync", ["uv", "sync", "--frozen", "--extra", "dev", "--extra", "type"]),
35+
("py", "uv-sync", ["uv", "sync", "--frozen", "--extra", "dev", "--extra", "type", "--no-dev"]),
3636
("py", "freeze", [uv, "--color", "never", "pip", "freeze"]),
3737
("py", "commands[0]", ["python", "hello"]),
3838
]
@@ -62,7 +62,32 @@ def test_uv_lock_command(tox_project: ToxProjectCreator) -> None:
6262
"venv",
6363
[uv, "venv", "-p", sys.executable, "--allow-existing", "-v", str(project.path / ".tox" / "py")],
6464
),
65-
("py", "uv-sync", ["uv", "sync", "--frozen", "--extra", "dev", "--extra", "type"]),
65+
("py", "uv-sync", ["uv", "sync", "--frozen", "--extra", "dev", "--extra", "type", "--no-dev"]),
6666
("py", "commands[0]", ["python", "hello"]),
6767
]
6868
assert calls == expected
69+
70+
71+
def test_uv_lock_with_dev(tox_project: ToxProjectCreator) -> None:
72+
project = tox_project({
73+
"tox.ini": """
74+
[testenv]
75+
runner = uv-venv-lock-runner
76+
with_dev = True
77+
"""
78+
})
79+
execute_calls = project.patch_execute(lambda r: 0 if r.run_id != "venv" else None)
80+
result = project.run("-vv")
81+
result.assert_success()
82+
83+
calls = [(i[0][0].conf.name, i[0][3].run_id, i[0][3].cmd) for i in execute_calls.call_args_list]
84+
uv = find_uv_bin()
85+
expected = [
86+
(
87+
"py",
88+
"venv",
89+
[uv, "venv", "-p", sys.executable, "--allow-existing", "-v", str(project.path / ".tox" / "py")],
90+
),
91+
("py", "uv-sync", ["uv", "sync", "--frozen"]),
92+
]
93+
assert calls == expected

0 commit comments

Comments
 (0)