Skip to content

Commit

Permalink
Refactor documentation of extension autoloading
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Mar 27, 2024
1 parent dfe5b84 commit 1672826
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 6 additions & 2 deletions docs/src/compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ The `juliacall` IPython extension adds these features to your IPython session:

The extension is experimental and unstable - the API can change at any time.

Enable the extension with `%load_ext juliacall`.
See [the IPython docs](https://ipython.readthedocs.io/en/stable/config/extensions/).
You can explicitly enable the extension with `%load_ext juliacall`, but
it will automatically be loaded if `juliacall` is imported and IPython is detected.
You can disable this behavior with an [environment variable](@ref julia-config).

The `%%julia` cell magic can synchronise variables between Julia and Python by listing them
on the first line:
Expand All @@ -88,6 +89,9 @@ In [5]: z
Out[5]: '2^8 = 256'
```

Also see [the IPython docs](https://ipython.readthedocs.io/en/stable/config/extensions/)
for more information on extensions.

## Asynchronous Julia code (including Makie)

Asynchronous Julia code will not normally run while Python is executing, unless it is in a
Expand Down
1 change: 1 addition & 0 deletions docs/src/juliacall.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ be configured in two ways:
| `-X juliacall-sysimage=<file>` | `PYTHON_JULIACALL_SYSIMAGE=<file>` | Use the given system image. |
| `-X juliacall-threads=<N\|auto>` | `PYTHON_JULIACALL_THREADS=<N\|auto>` | Launch N threads. |
| `-X juliacall-warn-overwrite=<yes\|no>` | `PYTHON_JULIACALL_WARN_OVERWRITE=<yes\|no>` | Enable or disable method overwrite warnings. |
| `-X juliacall-autoload-ipython-extension=<yes\|no>` | `PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=<yes\|no>` | Enable or disable IPython extension autoloading. |
6 changes: 1 addition & 5 deletions pysrc/juliacall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,7 @@ def jlstr(x):
if CONFIG['autoload_ipython_extension'] is None:
# Only let the user know if it was not explicitly set
print(
"Detected IPython. Loading juliacall extension. To disable, you can either "
"set the environment variable PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=no or pass the "
"command line argument '-X juliacall-autoload-ipython-extension=no'. Inside Jupyter, you can "
"do this with `import os; os.environ['PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION'] = 'no'`. "
"To suppress this message, set PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=yes."
"Detected IPython. Loading juliacall extension. See https://juliapy.github.io/PythonCall.jl/stable/compat/#IPython"
)

load_ipython_extension(get_ipython())
Expand Down

0 comments on commit 1672826

Please sign in to comment.