@@ -248,32 +248,25 @@ def jlstr(x):
248
248
"PYTHON_JULIACALL_HANDLE_SIGNALS=no."
249
249
)
250
250
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 }:
254
254
try :
255
- # Get IPython `InteractiveShell` instance
256
255
get_ipython = sys .modules ['IPython' ].get_ipython
257
256
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 :
265
258
# Only let the user know if it was not explicitly set
266
259
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."
272
265
)
273
266
274
267
load_ipython_extension (get_ipython ())
275
268
except Exception as e :
276
- if CONFIG ['autoload_extensions ' ] == 'yes' :
269
+ if CONFIG ['autoload_ipython_extension ' ] == 'yes' :
277
270
# Only warn if the user explicitly requested the extension to be loaded
278
271
warnings .warn (
279
272
"Could not load juliacall extension in Jupyter notebook: " + str (e )
0 commit comments