Skip to content

Commit

Permalink
Make sync prefer system python instead of uv managed
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Dec 28, 2024
1 parent 75dcdc1 commit cecc758
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/tox_uv/_run_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def register_config(self) -> None:

def _setup_env(self) -> None:
super()._setup_env()
cmd = ["uv", "sync", "--frozen"]
cmd = ["uv", "sync", "--frozen", "--python-preference=system"]
for extra in cast("set[str]", sorted(self.conf["extras"])):
cmd.extend(("--extra", extra))
if not self.conf["with_dev"]:
Expand Down
14 changes: 7 additions & 7 deletions tests/test_tox_uv_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_uv_lock_list_dependencies_command(tox_project: ToxProjectCreator) -> No
"venv",
[uv, "venv", "-p", sys.executable, "--allow-existing", "-v", str(project.path / ".tox" / "py")],
),
("py", "uv-sync", ["uv", "sync", "--frozen", "--extra", "dev", "--extra", "type", "--no-dev", "-v"]),
("py", "uv-sync", ["uv", "sync", "--frozen", "--python-preference=system", "--extra", "dev", "--extra", "type", "--no-dev", "-v"]),
("py", "freeze", [uv, "--color", "never", "pip", "freeze"]),
("py", "commands[0]", ["python", "hello"]),
]
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_uv_lock_command(tox_project: ToxProjectCreator, verbose: str) -> None:
"venv",
[uv, "venv", "-p", sys.executable, "--allow-existing", *v_args, str(project.path / ".tox" / "py")],
),
("py", "uv-sync", ["uv", "sync", "--frozen", "--extra", "dev", "--extra", "type", "--no-dev", *v_args]),
("py", "uv-sync", ["uv", "sync", "--frozen", "--python-preference=system","--extra", "dev", "--extra", "type", "--no-dev", *v_args]),
("py", "commands[0]", ["python", "hello"]),
]
assert calls == expected
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_uv_lock_with_dev(tox_project: ToxProjectCreator) -> None:
"venv",
[uv, "venv", "-p", sys.executable, "--allow-existing", "-v", str(project.path / ".tox" / "py")],
),
("py", "uv-sync", ["uv", "sync", "--frozen", "-v"]),
("py", "uv-sync", ["uv", "sync", "--frozen", "--python-preference=system", "-v"]),
]
assert calls == expected

Expand Down Expand Up @@ -126,7 +126,7 @@ def test_uv_lock_with_install_pkg(tox_project: ToxProjectCreator, name: str) ->
"venv",
[uv, "venv", "-p", sys.executable, "--allow-existing", "-v", str(project.path / ".tox" / "py")],
),
("py", "uv-sync", ["uv", "sync", "--frozen", "--no-dev", "--no-install-project", "-v"]),
("py", "uv-sync", ["uv", "sync", "--frozen", '--python-preference=system', "--no-dev", "--no-install-project", "-v"]),
(
"py",
"install_external",
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_uv_sync_extra_flags(tox_project: ToxProjectCreator) -> None:
(
"py",
"uv-sync",
["uv", "sync", "--frozen", "--no-editable", "--inexact"],
["uv", "sync", "--frozen", '--python-preference=system', "--no-editable", "--inexact"],
),
("py", "commands[0]", ["python", "hello"]),
]
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_uv_sync_extra_flags_toml(tox_project: ToxProjectCreator) -> None:
(
"py",
"uv-sync",
["uv", "sync", "--frozen", "--no-editable", "--inexact"],
["uv", "sync", "--frozen", "--python-preference=system", "--no-editable", "--inexact"],
),
("py", "commands[0]", ["python", "hello"]),
]
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_uv_sync_dependency_groups(tox_project: ToxProjectCreator) -> None:
(
"py",
"uv-sync",
["uv", "sync", "--frozen", "--group", "test", "--group", "type"],
["uv", "sync", "--frozen", '--python-preference=system', "--group", "test", "--group", "type"],
),
("py", "commands[0]", ["python", "hello"]),
]
Expand Down

0 comments on commit cecc758

Please sign in to comment.