From eaee700c38456adba074a2ac9e36aec57e073251 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Wed, 25 Feb 2026 10:48:54 +0100 Subject: [PATCH] Have a static banner when setting SOURCE_DATE_EPOCH This should help with things like jupyterlab/jupyterlab#18552, and allow screenshots to be reproducible. --- IPython/core/interactiveshell.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index a323360288..9f7c7254d8 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -38,6 +38,7 @@ from typing import Literal, Optional, Tuple from collections.abc import Sequence from warnings import warn +import textwrap from IPython.external.pickleshare import PickleShareDB @@ -1023,6 +1024,18 @@ def restore_sys_module_state(self): @property def banner(self): + if (when := os.environ.get("SOURCE_DATE_EPOCH", None)) is not None: + from datetime import datetime + + date = datetime.fromtimestamp(int(when)) + return textwrap.dedent( + f""" + Python 3.y.z | Packaged with love | (main, {date.strftime("%A, %d %B %Y")}) [Compiler] + Type 'copyright', 'credits' or 'license' for more information + IPython 9.y.z -- An enhanced Interactive Python. Type '?' for help. + Tip: unset SOURCE_DATE_EPOCH to restore dynamic banner. + """ + ).lstrip() banner = self.banner1 if self.profile and self.profile != 'default': banner += '\nIPython profile: %s\n' % self.profile