Repository: python-wheel-build/fromager

Issue:
Add package-version-specific changelog to settings
- Add a new field `changelog` to the per package setting
- Include a way to specify versions
- We just care about the length of the changelog (the ordering of the entries doesn't matter to us. it is on the user to maintain the ordering)

Agreed upon template:
```yaml
torch:
  changelog:
    "2.3.1":
      - rebuild for xyz

```

Discussion:

Patch:
diff --git a/src/fromager/settings.py b/src/fromager/settings.py
index c90bc91..5fc5aa1 100644
--- a/src/fromager/settings.py
+++ b/src/fromager/settings.py
@@ -96,6 +96,11 @@ class Settings:
             return sdist_root_dir / relative_build_dir
         return sdist_root_dir
 
+    def build_tag(self, pkg: str, version: Version | str) -> int:
+        p = self.get_package_settings(pkg)
+        changelog = p.get("changelog", {}).get(str(version), [])
+        return len(changelog)
+
     def get_package_settings(self, pkg: str) -> dict[str, dict[str, str]]:
         p = self.packages()
         return self._return_value_or_default(


Test patch:
diff --git a/tests/test_settings.py b/tests/test_settings.py
index 7949083..49e12b7 100644
--- a/tests/test_settings.py
+++ b/tests/test_settings.py
@@ -3,6 +3,7 @@ import textwrap
 
 import pytest
 from packaging.requirements import Requirement
+from packaging.version import Version
 
 from fromager import settings
 
@@ -141,6 +142,23 @@ def test_escape_sdist_root_build_dir():
         str(s.build_dir("foo", sdist_root_dir)).startswith("/foo/bar")
 
 
+def test_changelog():
+    s = settings._parse(
+        textwrap.dedent("""
+    packages:
+      foo:
+        changelog:
+          "2.1.0":
+            - "rebuild abc"
+            - "rebuild xyz"
+    """)
+    )
+    assert s.build_tag("foo", Version("2.1.0")) == 2
+    assert s.build_tag("foo", "2.1.0") == 2
+    assert s.build_tag("foo", "3.1.0") == 0
+    assert s.build_tag("bar", "2.1.0") == 0
+
+
 def test_resolve_template_with_no_template():
     req = Requirement("foo==1.0")
     assert settings._resolve_template(None, req, "1.0") is None