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
4 changes: 3 additions & 1 deletion src/packaging/pylock.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,9 @@ def select(
.. versionchanged:: 26.3
Added the *prefer_sdist_predicate* parameter.
"""
compatible_tags_selector = create_compatible_tags_selector(tags or sys_tags())
compatible_tags_selector = create_compatible_tags_selector(
tags if tags is not None else sys_tags()
)

# #. Gather the extras and dependency groups to install and set ``extras`` and
# ``dependency_groups`` for marker evaluation, respectively.
Expand Down
28 changes: 28 additions & 0 deletions tests/test_pylock_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,34 @@ def test_missing_sdist_fallback() -> None:
list(pylock.select())


def test_empty_tags_selects_sdist_instead_of_host_compatible_wheel() -> None:
pylock = _pylock_with_wheel_and_sdist()

selected = list(
pylock.select(
tags=[],
environment=_py312_linux.environment,
)
)

assert len(selected) == 1
assert isinstance(selected[0][1], PackageSdist)


def test_empty_tags_rejects_wheel_only_lock() -> None:
pylock = _pylock_with_wheel_and_sdist(include_sdist=False)

with pytest.raises(
PylockSelectError, match=r"No wheel found matching .* and no sdist available"
):
list(
pylock.select(
tags=[],
environment=_py312_linux.environment,
)
)


def _pylock_with_wheel_and_sdist(
*, wheel_python_tag: str | None = "py3", include_sdist: bool = True
) -> Pylock:
Expand Down
Loading