Hi Chris! On Mon, Feb 27, 2023 at 07:53:12AM +0000, Chris Lamb wrote: > Whilst working on the Reproducible Builds effort [0] we noticed > that pyproject-api could not be built reproducibly.
That's unfortunate! Sorry for not realizing it before you did. For what it's worth, this package was uploaded as a new dependency of tox 4. It looks like tox 4.4.6-1 (uploaded to experimental last week) suffers from the same issue as well. I will handle it there as soon as we conclude our resolution of this one -- no need for a separate bug :) > This is because the documentation embeds the current date in the > build system's current timezone. A patch is attached that uses > SOURCE_DATE_EPOCH [1] if available. > > ... > > + html_theme = "furo" > +-html_title, html_last_updated_fmt = "pyproject-api docs", > datetime.now().isoformat() > ++build_date = datetime.utcfromtimestamp( > ++ int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) > ++) > ++html_title, html_last_updated_fmt = "pyproject-api docs", > build_date.isoformat() Looking at Sphinx's documentation, it looks like html_last_updated_fmt, as the name hints, is supposed to be the format string, not the actual date. (A literal date works as a format because anything that's not percent-encoded is passed on unmodified. So I think that's just a happy accident.) I checked the Sphinx source code, and it looks like the string is used in prepare_writing() from builders/html/__init__.py, which in turn passes it on as an argument to format_date() from util/i18n.py. It looks like format_date() has support for SOURCE_DATE_EPOCH. So from what I can tell, a much simpler patch would be to set html_last_updated_fmt to "%Y-%m-%dT%H:%M:%S.%f" for the equivalent ISO 8601 string (or even something with less accuracy) -- no need to fiddle with the datetime module, or SOURCE_DATE_EPOCH at all. I know you've gone to great lengths to make Sphinx docs reproducible across the board, so I'm leaning on your experience to let me know if I'm missing something here before I patch it locally and pass it on to the two upstream projects. Looking forward to your feedback. Best, Faidon