Skip to main content

doppler-env

The doppler-env package automates the injection of Doppler secrets as environment variables into any Python application and works in the terminal, PyCharm, and Visual Studio Code.

Motivation

The Doppler CLI provides the easiest method of injecting secrets into your application:

doppler run -- python app.py

But when debugging with PyCharm or Visual Studio Code, a vendor-specific Python entry-point is used, preventing the Doppler CLI from acting as the application runner. At Doppler, we go to great lengths to prevent secrets ending up on developer's machines so downloading secrets to a .env file wasn't an option.

Thanks to Python's Site configuration hook via a path configuration file, we can replicate the doppler run workflow by fetching the secrets via the Doppler CLI (recommended) or API and injecting into your Python application process prior to your code by being executed.

Setup

Ensure you have installed the Doppler CLI locally and have created a Doppler Project. Then authorize the Doppler CLI to retrieve secrets from your workplace by running:

doppler login

Then install doppler-env in your local development environment or add it to the list of dev specific dependencies:

pip install doppler-env

Configuration

First, define the DOPPLER_ENV environment variable in your IDE, editor, or terminal to trigger the injection of secrets:

export DOPPLER_ENV=1

You can enable logging for troubleshooting purposes by setting the DOPPLER_ENV_LOGGING environment variable:

export DOPPLER_ENV_LOGGING=1

Then configure which secrets to fetch for your application by either using the CLI in the root directory of your application:

doppler setup

Or set the DOPPLER_PROJECT and DOPPLER_CONFIG environment variables in your debug configuration within PyCharm or Visual Studio Code.

Now whenever the Python interpreter is invoked for your application, secrets will be injected prior to your application being run:

python app.py

# >> [doppler-env]: DOPPLER_ENV environment variable set. Fetching secrets using Doppler CLI

In restrictive environments where the use of the Doppler CLI isn't possible, set a DOPPLER_TOKEN environment variable with a Service Token to fetch secrets directly from the Doppler API:

export DOPPLER_TOKEN='dp.st.dev.xxxxxxx'

python app.py

# >> [doppler-env]: DOPPLER_ENV and DOPPLER_TOKEN environment variable set. Fetching secrets from Doppler API

Acknowledgements

This approach to injecting environment variables was inspired by patch-env.

Issues

For any bug reports, issues, or enhancements, please create a repository issue.

Support

You can get support in the Doppler community forum, find us on Twitter, and for bugs or feature requests, create an issue on the DopplerHQ/python-doppler-env GitHub repository.

If you need help, either use our in-product support or head over to the Doppler Community Forum to get your questions answered by a member of the Doppler support team or

Metadata

Release files for doppler-env 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doppler-env 0.3.1
File Size Uploaded
doppler_env-0.3.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for doppler-env 0.3.1
File Interpreter ABI Platform
doppler_env-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / doppler_env-0.3.1.tar.gz

Download URL doppler_env-0.3.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d187c2cf6a0dec677c00af502d59b382d507d69cd9805ea9e8211860bd0aa0f7
BLAKE2b-256 checksum
How to use checksums
8f8b38b4f570db3a1c68f84565078991fca249ffa878968e653e34e5442660a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / doppler_env-0.3.1-py3-none-any.whl

Download URL doppler_env-0.3.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c80437f875c7bb85c980e7a3bf96fff594d1e1b05b99b49b02e673fbaa2d65c
BLAKE2b-256 checksum
How to use checksums
766b46293737fd8c854f34f099529e2606b366176cdcdee119e1474e47e367c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page