Skip to content

Commit 5467339

Browse files
committed
Make the documentation build reproducibly
Whilst working on the Reproducible Builds effort [0], I noticed that mpl-sphinx-theme could not be built reproducibly. This is because the documentation embedded the current build year. This patch changes the behaviour of the Sphinx documentation so that it can that optionally use SOURCE_DATE_EPOCH [1] as the source of this value instead. I originally filed this in Debian as bug #1005826 [2]. [0] https://reproducible-builds.org/ [1] https://reproducible-builds.org/specs/source-date-epoch/ [2] https://bugs.debian.org/1005826
1 parent 81fd66a commit 5467339

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
import time
13
import datetime
24

35
# Configuration file for the Sphinx documentation builder for
@@ -6,11 +8,17 @@
68
# Release mode enables optimizations and other related options.
79
is_release_build = tags.has('release') # noqa
810

11+
# Parse year using SOURCE_DATE_EPOCH, falling back to current time.
12+
# https://reproducible-builds.org/specs/source-date-epoch/
13+
build_date = datetime.datetime.utcfromtimestamp(
14+
int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
15+
)
16+
917
# -- Project information -----------------------------------------------------
1018

1119
project = "Matplotlib Sphinx Theme"
1220
copyright = (
13-
f"2012 - {datetime.datetime.now().year} The Matplotlib development team"
21+
f"2012 - {build_date.year} The Matplotlib development team"
1422
)
1523
author = "Matplotlib Developers"
1624

0 commit comments

Comments
 (0)