File reproducible.patch of Package python-sphinx-gallery
commit c9b4c15cb91c80e06f7b6e1eddca1075c81c5adb
Author: Bernhard M. Wiedemann <bwiedemann+git@suse.de>
Date: Fri Oct 4 14:35:52 2024 +0000
Allow to disable writing computation times
to allow for reproducible builds.
If SOURCE_DATE_EPOCH indicates that a reproducible build is wanted,
default to not write durations.
diff --git a/sphinx_gallery/gen_gallery.py b/sphinx_gallery/gen_gallery.py
index c3b29f4..93bf565 100644
--- a/sphinx_gallery/gen_gallery.py
+++ b/sphinx_gallery/gen_gallery.py
@@ -111,6 +111,7 @@ DEFAULT_GALLERY_CONF = {
"expected_failing_examples": set(),
"thumbnail_size": (400, 280), # Default CSS does 0.4 scaling (160, 112)
"min_reported_time": 0,
+ "write_computation_times": os.getenv("SOURCE_DATE_EPOCH") is None,
"binder": {},
"jupyterlite": {},
"promote_jupyter_magic": False,
@@ -927,6 +928,8 @@ def write_computation_times(gallery_conf, target_dir, costs):
costs: List[Dict]
List of dicts of computation costs and paths, see gen_rst.py for details.
"""
+ if not gallery_conf['write_computation_times']:
+ return
total_time = sum(cost["t"] for cost in costs)
if target_dir is None: # all galleries together
out_dir = gallery_conf["src_dir"]