Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rsconnect/subprocesses/inspect_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ def uv_export(dirname: str, lock_filename: str, uv_path: str = "uv"):
"--offline",
"--no-header",
"--no-emit-project",
"--no-dev",
"--no-default-groups",
"--output-file",
output_path,
],
Expand Down
35 changes: 35 additions & 0 deletions tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,41 @@ def test_uv_lock_export(tmp_path, monkeypatch, fallback):
assert Manifest(environment=env).data["python"]["package_manager"]["version"] == expected_uv_version


@pytest.mark.parametrize("default_groups", ["", '[tool.uv]\ndefault-groups = ["dev", "lint"]\n'])
def test_uv_lock_export_excludes_dependency_groups(tmp_path, default_groups):
packages = {
"runtime-pkg": [],
"dev-pkg": ["transitive-pkg"],
"transitive-pkg": [],
"lint-pkg": [],
"other-pkg": [],
}
for name, dependencies in packages.items():
package_dir = tmp_path / name
package_dir.mkdir()
(package_dir / "pyproject.toml").write_text(
f'[project]\nname = "{name}"\nversion = "1.0.0"\ndependencies = {dependencies!r}\n'
+ ('[tool.uv.sources]\ntransitive-pkg = { path = "../transitive-pkg" }\n' if dependencies else ""),
encoding="utf-8",
)

sources = "".join(f'{name} = {{ path = "{name}" }}\n' for name in packages)
(tmp_path / "pyproject.toml").write_text(
'[project]\nname = "demo"\nversion = "1.0.0"\n'
'dependencies = ["runtime-pkg"]\n'
'[dependency-groups]\ndev = ["dev-pkg"]\nlint = ["lint-pkg"]\nother = ["other-pkg"]\n'
f"{default_groups}[tool.uv.sources]\n{sources}",
encoding="utf-8",
)
subprocess.run([uv.find_uv_bin(), "lock", "--offline"], cwd=tmp_path, check=True)

env = Environment.create_python_environment(str(tmp_path), requirements_file="uv.lock", python=sys.executable)

assert "./runtime-pkg" in env.contents
for name in ("dev-pkg", "transitive-pkg", "lint-pkg", "other-pkg"):
assert name not in env.contents


@pytest.mark.parametrize("encoding", ["utf-8", "utf-8-sig"])
def test_pyproject_dependencies(tmp_path, encoding):
project_dir = tmp_path / "project"
Expand Down
Loading