Source: towncrier
Version: 24.8.0-2
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: timestamps toolchain
X-Debbugs-Cc: [email protected]

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed that
towncrier generates nondeterministic output and is the cause of some
unreproducible packages.

For example, here is src:python-rosettasciio:

│ │ │ ├── ./usr/share/doc/python-rosettasciio-doc/html/changes.html
│ │ │ │ @@ -443,16 +443,16 @@
│ │ │ │  <p>Changelog entries for the development version are available at
│ │ │ │  <a class="reference external" 
href="https://rosettasciio.readthedocs.io/en/latest/changes.html";>https://rosettasciio.readthedocs.io/en/latest/changes.html</a></p>
│ │ │ │ -<section id="release-unreleased-2026-07-30">
│ │ │ │ -<h2> [UNRELEASED] (2026-07-30)<a class="headerlink" 
href="#release-unreleased-2026-07-30" title="Link to this heading">#</a></h2>
│ │ │ │ +<section id="release-unreleased-2027-09-02">
│ │ │ │ +<h2> [UNRELEASED] (2027-09-02)<a class="headerlink" 
href="#release-unreleased-2027-09-02" title="Link to this heading">#</a></h2>
│ │ │ │  <section id="bug-fixes">

A patch is attached to make these values seeded from SOURCE_DATE_EPOCH (if
available).

  [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      [email protected] / chris-lamb.co.uk
       `-
diff --git src/towncrier/build.py src/towncrier/build.py
index 3d18392..da4c799 100644
--- src/towncrier/build.py
+++ src/towncrier/build.py
@@ -9,8 +9,8 @@ from __future__ import annotations
 
 import os
 import sys
+import time
 
-from datetime import date
 from pathlib import Path
 
 import click
@@ -32,7 +32,10 @@ else:
 
 
 def _get_date() -> str:
-    return date.today().isoformat()
+    return time.strftime(
+        "%Y-%m-%d",
+        time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
+    )
 
 
 def _validate_answer(ctx: Context, param: Option, value: bool) -> bool:

Reply via email to