Skip to content

Commit 1185d12

Browse files
authored
Expose session start file in __file__. (#1078)
1 parent 5bda9c0 commit 1185d12

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ipykernel/ipkernel.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import builtins
55
import getpass
6+
import os
67
import signal
78
import sys
89
import threading
@@ -126,6 +127,11 @@ def __init__(self, **kwargs):
126127
compiler_class=XCachingCompiler,
127128
)
128129
self.shell.displayhook.session = self.session
130+
131+
jupyter_session_name = os.environ.get('JPY_SESSION_NAME')
132+
if jupyter_session_name:
133+
self.shell.user_ns['__file__'] = jupyter_session_name
134+
129135
self.shell.displayhook.pub_socket = self.iopub_socket
130136
self.shell.displayhook.topic = self._topic("execute_result")
131137
self.shell.display_pub.session = self.session

0 commit comments

Comments
 (0)