Skip to content

fix(dependencies): sort requirements files - #1330

Merged
mergify[bot] merged 1 commit into
python-wheel-build:mainfrom
mprpic:fix/sort-requirements-files
Sep 15, 2026
Merged

mergify[bot] merged 1 commit into
python-wheel-build:mainfrom
mprpic:fix/sort-requirements-files

Conversation

@mprpic

@mprpic mprpic commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

_write_requirements_file() wrote requirement sets in iteration order so rebuilds of identical sources could produced different files even though the content was the same.

Pull Request Description

What

Sort the fromager-build-system-requirements.txt file.

Why

Reproducibility.

Reproducer:

> podman run --rm ghcr.io/astral-sh/uv:python3.12-bookworm bash -c '
set -e
base=https://packages.redhat.com/api/pulp-content/public-rhai/rhoai/3.6-EA2
whl=tqdm-4.70.1-1-py3-none-any.whl
cd /tmp
for v in cpu-ubi9-prod spyre-ubi9-prod; do
  mkdir -p $v
  curl -sSf -o $v/$whl "$base/$v/$whl"
  python3 -m zipfile -e $v/$whl $v/x
  echo "== $v"
  cat $v/x/tqdm-4.70.1.dist-info/fromager-build-system-requirements.txt
done
'
== cpu-ubi9-prod
setuptools>=42
setuptools-scm[toml]>=3.4
== spyre-ubi9-prod
setuptools-scm[toml]>=3.4
setuptools>=42

`_write_requirements_file()` wrote requirement sets in iteration order
so rebuilds of identical sources could produced different files even
though the content was the same.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Martin Prpič <mprpic@redhat.com>
@mprpic
mprpic requested a review from a team as a code owner September 15, 2026 19:38
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: ebcf19a7-a9f3-41e0-b5e5-92c65ac3e86e

📥 Commits

Reviewing files that changed from the base of the PR and between 52457f1 and a8609e5.

📒 Files selected for processing (2)
  • src/fromager/dependencies.py
  • tests/test_dependencies.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

_write_requirements_file now sorts requirements by their string representation before writing them. This applies to requirement files generated for build-system, build-backend, build-sdist, and install requirements. A regression test verifies alphabetical ordering for requirements with specifiers and extras.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to a8609

This change deterministically orders generated requirement files without an identified current-head risk.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description explains that sorting requirement files fixes non-deterministic output and improves reproducibility. It matches the changeset.
Title check ✅ Passed The title clearly and concisely identifies the main change: sorting requirements files in the dependencies logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added the ci label Sep 15, 2026

@rd4398 rd4398 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mergify
mergify Bot merged commit a392a82 into python-wheel-build:main Sep 15, 2026
39 checks passed
@mergify

mergify Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mprpic
mprpic deleted the fix/sort-requirements-files branch September 16, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants