From 1fcb1b5bc195922602ef77a6e3fba2cb5c1c08c7 Mon Sep 17 00:00:00 2001 From: Tim Hughes Date: Wed, 15 Jan 2020 10:40:01 +0000 Subject: [PATCH] [docs] mention variable expansion in `.env` files fix #3610 --- docs/advanced.rst | 17 +++++++++++++++++ news/4100.doc.rst | 1 + 2 files changed, 18 insertions(+) create mode 100644 news/4100.doc.rst diff --git a/docs/advanced.rst b/docs/advanced.rst index 9efb798eb1..014bd62d27 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -344,6 +344,21 @@ If a ``.env`` file is present in your project, ``$ pipenv shell`` and ``$ pipenv >>> os.environ['HELLO'] 'WORLD' +Shell like variable expansion is available in ``.env`` files using `${VARNAME}` syntax.:: + + $ cat .env + CONFIG_PATH=${HOME}/.config/foo + + $ pipenv run python + Loading .env environment variables… + Python 3.7.6 (default, Dec 19 2019, 22:52:49) + [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux + Type "help", "copyright", "credits" or "license" for more information. + >>> import os + >>> os.environ['CONFIG_PATH'] + '/home/kennethreitz/.config/foo' + + This is very useful for keeping production credentials out of your codebase. We do not recommend committing ``.env`` files into source control! @@ -355,6 +370,8 @@ To prevent pipenv from loading the ``.env`` file, set the ``PIPENV_DONT_LOAD_ENV $ PIPENV_DONT_LOAD_ENV=1 pipenv shell +See `theskumar/python-dotenv `_ for more information on ``.env`` files. + ☤ Custom Script Shortcuts ------------------------- diff --git a/news/4100.doc.rst b/news/4100.doc.rst new file mode 100644 index 0000000000..050bdcca96 --- /dev/null +++ b/news/4100.doc.rst @@ -0,0 +1 @@ +More documentation for ``.env`` files