Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e662a43

Browse files
committed
Have a static banner when setting SOURCE_DATE_EPOCH
This should help with things like jupyterlab/jupyterlab#18552, and allow screenshots to be reproducible.
1 parent 2ef6876 commit e662a43

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

IPython/core/interactiveshell.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from typing import Literal, Optional, Tuple
3939
from collections.abc import Sequence
4040
from warnings import warn
41+
import textwrap
4142

4243
from IPython.external.pickleshare import PickleShareDB
4344

@@ -1023,6 +1024,18 @@ def restore_sys_module_state(self):
10231024

10241025
@property
10251026
def banner(self):
1027+
if (when := os.environ.get("SOURCE_DATE_EPOCH", None)) is not None:
1028+
from datetime import datetime
1029+
1030+
date = datetime.fromtimestamp(int(when))
1031+
return textwrap.dedent(
1032+
f"""
1033+
Python 3.y.z | Packaged with love | (main, {date.strftime("%A, %d %B %Y")}) [Compiler]
1034+
Type 'copyright', 'credits' or 'license' for more information
1035+
IPython 9.y.z -- An enhanced Interactive Python. Type '?' for help.
1036+
Tip: unset SOURCE_DATE_EPOCH to restore dynamic banner.
1037+
"""
1038+
).lstrip()
10261039
banner = self.banner1
10271040
if self.profile and self.profile != 'default':
10281041
banner += '\nIPython profile: %s\n' % self.profile

0 commit comments

Comments
 (0)