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: 1 addition & 1 deletion src/fromager/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def _write_requirements_file(
filename: pathlib.Path,
) -> None:
with open(filename, "w") as f:
for r in requirements:
for r in sorted(requirements, key=str):
f.write(f"{r}\n")


Expand Down
14 changes: 14 additions & 0 deletions tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ def test_get_build_system_dependencies_cached(
assert results == set([Requirement("foo==1.0")])


def test_write_requirements_file_sorted(tmp_path: pathlib.Path) -> None:
"""Verify the file content does not depend on input or set order."""
req_file = tmp_path / "build-system-requirements.txt"
requirements = [
Requirement("setuptools>=42"),
Requirement("setuptools-scm[toml]>=3.4"),
Requirement("cython"),
]
dependencies._write_requirements_file(requirements, req_file)
assert req_file.read_text() == (
"cython\nsetuptools-scm[toml]>=3.4\nsetuptools>=42\n"
)


@patch("fromager.dependencies._write_requirements_file")
@_clean_build_artifacts
@pytest.mark.network
Expand Down
Loading