Skip to main content

A Poetry plugin to automatically load environment variables from .env files

Project description

Poetry Dotenv Plugin

CI

A Poetry plugin that automatically loads environment variables from .env files into the environment before poetry commands are run.

Supports Python 3.7+

$ cat .env
MY_ENV_VAR='Hello World'

$ poetry run python -c 'import os; print(os.environ.get("MY_ENV_VAR"))'
Hello World

This plugin depends on the python-dotenv package for its functionality and therefore also supports features that python-dotenv supports. Interpolating variables using POSIX variable expansion for example.

Origins

Initial implementation based on the event handler application plugin example in the Poetry docs.

Install

poetry self add poetry-dotenv-plugin

Coming from Pipenv

If you are transitioning from pipenv there shouldn't be much to change with regard to the .env loading. If you were a user of pipenv's environment variables to control .env loading then you can use the analogous environment variables listed below.

Pipenv env var Poetry env var
PIPENV_DOTENV_LOCATION POETRY_DOTENV_LOCATION
PIPENV_DONT_LOAD_ENV POETRY_DONT_LOAD_ENV

Overriding existing environment variables

By default, this plugin will override existing environment variables. This is because this plugin was built to make onboarding for users coming from pipenv as seamless as possible. If you want to prevent existing environment variables from being overridden, you can set the POETRY_DOTENV_DONT_OVERRIDE environment variable to true.[^1]

[^1]: See #16 for background.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_dotenv_plugin-0.2.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

poetry_dotenv_plugin-0.2.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file poetry_dotenv_plugin-0.2.0.tar.gz.

File metadata

  • Download URL: poetry_dotenv_plugin-0.2.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for poetry_dotenv_plugin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9bdd0a96d81ba5f2e75bda7c8944e2c5132b0c615c44452770dd1e7f1aca62f6
MD5 bbeb889deb9f5f4bdeb6a9fe3bc0d0c5
BLAKE2b-256 8f7a6f329eee5b9e57669f00c12b6d2b811dc1b394741518f967a3ed75131dc8

See more details on using hashes here.

File details

Details for the file poetry_dotenv_plugin-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_dotenv_plugin-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc2fd816a96e32586afb6507f01de6070a8a50877207ae20efa7c6a75648143a
MD5 3f9c405a17ab7823c16c7109c4a070bc
BLAKE2b-256 746085248a2c3a983e9052fe1458e88ceb524a882dc718f223c910414a1ca63a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page