8000 Have a static banner when setting SOURCE_DATE_EPOCH by Carreau · Pull Request #15144 · ipython/ipython · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions IPython/core/interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
0