File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Falcon's documentation build process was not fully reproducible, as the output
2+ could vary with the build system's date. The issue was addressed by adding
3+ support for setting the build date via the
4+ `SOURCE_DATE_EPOCH <https://reproducible-builds.org/docs/source-date-epoch/ >`__
5+ standardized environment variable.
Original file line number Diff line number Diff line change 2121import multiprocessing
2222import os
2323import sys
24+ import time
2425
2526try :
2627 import falconry_pygments_theme
6566 for component in _version_components
6667)
6768
69+ # NOTE(vytas): Afford overriding the current date with SOURCE_DATE_EPOCH for
70+ # reproducible documentation builds.
71+ # (See also: https://reproducible-builds.org/docs/source-date-epoch/)
72+ build_date = datetime .datetime .fromtimestamp (
73+ int (os .environ .get ('SOURCE_DATE_EPOCH' , time .time ())), tz = datetime .timezone .utc
74+ )
6875
6976project = 'Falcon'
70- copyright = f'{ datetime . datetime . now () .year } Falcon Contributors'
77+ copyright = f'{ build_date .year } Falcon Contributors'
7178author = 'Kurt Griffiths et al.'
7279version = '.' .join (_version_components [0 :2 ])
7380release = falcon .__version__
Original file line number Diff line number Diff line change 2323import datetime
2424import enum
2525import itertools
26+ import os
2627import pathlib
2728import re
29+ import time
2830
2931import sphinx .util .docutils
3032
@@ -136,6 +138,17 @@ class FalconReleasesDirective(sphinx.util.docutils.SphinxDirective):
136138 required_arguments = 1
137139 has_content = True
138140
141+ @staticmethod
142+ def get_build_date ():
143+ # NOTE(vytas,bmwiedemann): Afford overriding the current date with
144+ # SOURCE_DATE_EPOCH for reproducible documentation builds.
145+ # (See also: https://reproducible-builds.org/docs/source-date-epoch/)
146+ build_date = datetime .datetime .fromtimestamp (
147+ int (os .environ .get ('SOURCE_DATE_EPOCH' , time .time ())),
148+ tz = datetime .timezone .utc ,
149+ )
150+ return build_date .date ()
151+
139152 def run (self ):
140153 changelog_path = pathlib .Path (self .arguments [0 ])
141154 if not changelog_path .is_absolute ():
@@ -184,7 +197,7 @@ def run(self):
184197 eol_date = (
185198 current_series [0 ].first .date + self ._OLDSTABLE_MAINTENANCE_PERIOD
186199 )
187- if datetime . date . today () < eol_date :
200+ if self . get_build_date () < eol_date :
188201 status = _ReleaseStatus .security
189202 # NOTE(vytas): Move to a new line because otherwise table
190203 # layout gets messed up in an unpleasant way.
Original file line number Diff line number Diff line change @@ -337,11 +337,17 @@ commands =
337337# --------------------------------------------------------------------
338338
339339[testenv:docs]
340+ # NOTE(vytas): For easy testing of reproducible documentation builds.
341+ # (See also: https://reproducible-builds.org/docs/source-date-epoch/)
342+ passenv = SOURCE_DATE_EPOCH
340343deps = -r{toxinidir}/requirements/docs
341344commands =
342345 sphinx-build -j auto -W -E -b html docs docs/_build/html []
343346
344347[testenv:towncrier]
348+ # NOTE(vytas): For easy testing of reproducible documentation builds.
349+ # (See also: https://reproducible-builds.org/docs/source-date-epoch/)
350+ passenv = SOURCE_DATE_EPOCH
345351deps = -r{toxinidir}/requirements/docs
346352 toml
347353 towncrier
You can’t perform that action at this time.
0 commit comments