#!/usr/bin/env python # coding: utf-8 # This notebook is part of the `nbsphinx` documentation: https://nbsphinx.readthedocs.io/. # # Configuring the Kernels # ## Kernel Name # # If we have multiple kernels installed, we can choose to override the kernel saved in the notebook using [nbsphinx_kernel_name](configuration.ipynb#nbsphinx_kernel_name): # ```python # nbsphinx_kernel_name = 'python-upstream-dev' # ``` # which uses the kernel named `python-upstream-dev` instead of the kernel name stored in the notebook. # ## Kernel Arguments # # We can pass arguments to the kernel by using # [nbsphinx_execute_arguments](configuration.ipynb#nbsphinx_execute_arguments), # for example to set [plot options](code-cells.ipynb#Plots): # # ```python # nbsphinx_execute_arguments = [ # "--InlineBackend.figure_formats={'svg', 'pdf'}", # ] # ``` # ## Environment Variables # # The contents of `os.environ` after the execution of `conf.py` will be passed as environment variables to the kernel. As an example, `MY_DUMMY_VARIABLE` has been set in [conf.py](conf.py) like this: # # ```python # import os # os.environ['MY_DUMMY_VARIABLE'] = 'Hello from conf.py!' # ``` # # ... and it can be checked in the notebook like this: # In[ ]: import os os.environ['MY_DUMMY_VARIABLE'] # This is useful if we want to edit `PYTHONPATH` in order to compile the documentation without installing the project: # ```python # import os # # src = os.path.abspath('../src') # os.environ['PYTHONPATH'] = src # ``` # If you are using https://mybinder.org/ and you want to define environment variables, # you should create a file `.binder/start` in your repository # (see [Binder docs](https://mybinder.readthedocs.io/en/latest/using/config_files.html#start-run-code-before-the-user-sessions-starts)) # containing definitions like this: # # ```bash # #!/bin/bash # export MY_DUMMY_VARIABLE="Hello from .binder/start!" # exec "$@" # ```