Skip to content
PL1

Add dot env file support

When the user don't provide an explicit kernel_dir, nor a global environment variable (KERNELS_<MISSION_NAME>), it should be possible to provide a .env file to provide custom values.

# .env.example file
#
# Global JUICE kernels folder
#
KERNELS_JUICE="/path/to/juice/kernels"

Currently, the user can use python-dotenv package and Jupyter extension to expend their environment variables:

%load_ext dotenv
%dotenv

kernels_dir = os.getenv('KERNELS_JUICE')

However, it is not part of the standard library and it should be fairy easy to support it directly.

Notes

  • Dotenv file, should be searched in the current working directory, then search lazily in the parents folders (stopped at the 1st parent that have a .env file).
  • Dotenv file values need to be double quoted.
  • Add a generic getenv(key, prefix='', suffix='') function can be implemented and used in TourConfig.
  • The location of the env variable source should be reported in the debugger.