Skip to content

Commit bd12335

Browse files
committed
Change parameter name to autoload_ipython_extension
1 parent 88dcb5f commit bd12335

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

pysrc/juliacall/__init__.py

+10-17
Original file line numberDiff line numberDiff line change
@@ -248,32 +248,25 @@ def jlstr(x):
248248
"PYTHON_JULIACALL_HANDLE_SIGNALS=no."
249249
)
250250

251-
# Next, automatically load the juliacall extension if we are in a Jupyter notebook
252-
CONFIG['autoload_extensions'] = choice('autoload_extensions', ['yes', 'no'])[0]
253-
if CONFIG['autoload_extensions'] in {'yes', None}:
251+
# Next, automatically load the juliacall extension if we are in IPython or Jupyter
252+
CONFIG['autoload_ipython_extension'] = choice('autoload_ipython_extension', ['yes', 'no'])[0]
253+
if CONFIG['autoload_ipython_extension'] in {'yes', None}:
254254
try:
255-
# Get IPython `InteractiveShell` instance
256255
get_ipython = sys.modules['IPython'].get_ipython
257256

258-
# This line is a check for the IPython kernel being loaded to the
259-
# interactive shell, so that we don't activate for other types of
260-
# interactive shells).
261-
if 'IPKernelApp' not in get_ipython().config:
262-
raise ImportError('console')
263-
264-
if CONFIG['autoload_extensions'] is None:
257+
if CONFIG['autoload_ipython_extension'] is None:
265258
# Only let the user know if it was not explicitly set
266259
print(
267-
"Detected Jupyter notebook. Loading juliacall extension. To disable, you can either "
268-
"set the environment variable PYTHON_JULIACALL_AUTOLOAD_EXTENSIONS=no or pass the "
269-
"command line argument '-X juliacall-autoload-extensions=no'. Inside Jupyter, you can "
270-
"do this with `import os; os.environ['PYTHON_JULIACALL_AUTOLOAD_EXTENSIONS'] = 'no'`. "
271-
"To suppress this message, set PYTHON_JULIACALL_AUTOLOAD_EXTENSIONS=yes."
260+
"Detected IPython. Loading juliacall extension. To disable, you can either "
261+
"set the environment variable PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=no or pass the "
262+
"command line argument '-X juliacall-autoload-ipython-extension=no'. Inside Jupyter, you can "
263+
"do this with `import os; os.environ['PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION'] = 'no'`. "
264+
"To suppress this message, set PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=yes."
272265
)
273266

274267
load_ipython_extension(get_ipython())
275268
except Exception as e:
276-
if CONFIG['autoload_extensions'] == 'yes':
269+
if CONFIG['autoload_ipython_extension'] == 'yes':
277270
# Only warn if the user explicitly requested the extension to be loaded
278271
warnings.warn(
279272
"Could not load juliacall extension in Jupyter notebook: " + str(e)

0 commit comments

Comments
 (0)