poetry-dotenv-plugin


Namepoetry-dotenv-plugin JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/mpeteuil/poetry-dotenv-plugin
SummaryA Poetry plugin to automatically load environment variables from .env files
upload_time2023-07-16 11:35:46
maintainer
docs_urlNone
authorMichael Peteuil
requires_python>=3.7,<4
licenseMIT
keywords poetry poetry-plugin plugin dotenv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Poetry Dotenv Plugin

[![CI](https://github.com/mpeteuil/poetry-dotenv-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/mpeteuil/poetry-dotenv-plugin/actions/workflows/build.yml)

A [Poetry](https://python-poetry.org/) plugin that automatically loads environment variables from `.env` files into the environment before poetry commands are run.

Supports Python 3.7+

```sh
$ 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](https://github.com/theskumar/python-dotenv) 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](https://python-poetry.org/docs/plugins/#event-handler).

## Install

```sh
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](https://pipenv.pypa.io/en/latest/advanced/#automatic-loading-of-env) 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](https://github.com/mpeteuil/poetry-dotenv-plugin/pull/16) for background.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mpeteuil/poetry-dotenv-plugin",
    "name": "poetry-dotenv-plugin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4",
    "maintainer_email": "",
    "keywords": "poetry,poetry-plugin,plugin,dotenv",
    "author": "Michael Peteuil",
    "author_email": "michael.peteuil@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8f/7a/6f329eee5b9e57669f00c12b6d2b811dc1b394741518f967a3ed75131dc8/poetry_dotenv_plugin-0.2.0.tar.gz",
    "platform": null,
    "description": "# Poetry Dotenv Plugin\n\n[![CI](https://github.com/mpeteuil/poetry-dotenv-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/mpeteuil/poetry-dotenv-plugin/actions/workflows/build.yml)\n\nA [Poetry](https://python-poetry.org/) plugin that automatically loads environment variables from `.env` files into the environment before poetry commands are run.\n\nSupports Python 3.7+\n\n```sh\n$ cat .env\nMY_ENV_VAR='Hello World'\n\n$ poetry run python -c 'import os; print(os.environ.get(\"MY_ENV_VAR\"))'\nHello World\n```\n\nThis plugin depends on the [`python-dotenv` package](https://github.com/theskumar/python-dotenv) for its functionality and therefore also supports features that `python-dotenv` supports. Interpolating variables using POSIX variable expansion for example.\n\n### Origins\n\nInitial implementation based on the event handler application plugin example in the [Poetry docs](https://python-poetry.org/docs/plugins/#event-handler).\n\n## Install\n\n```sh\npoetry self add poetry-dotenv-plugin\n```\n\n### Coming from Pipenv\n\nIf 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](https://pipenv.pypa.io/en/latest/advanced/#automatic-loading-of-env) to control `.env` loading then you can use the analogous environment variables listed below.\n\nPipenv env var | Poetry env var\n-------------- | ----------------------\nPIPENV_DOTENV_LOCATION | POETRY_DOTENV_LOCATION\nPIPENV_DONT_LOAD_ENV | POETRY_DONT_LOAD_ENV\n\n### Overriding existing environment variables\n\nBy 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]\n\n[^1]: See [#16](https://github.com/mpeteuil/poetry-dotenv-plugin/pull/16) for background.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Poetry plugin to automatically load environment variables from .env files",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/mpeteuil/poetry-dotenv-plugin",
        "Repository": "https://github.com/mpeteuil/poetry-dotenv-plugin"
    },
    "split_keywords": [
        "poetry",
        "poetry-plugin",
        "plugin",
        "dotenv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "746085248a2c3a983e9052fe1458e88ceb524a882dc718f223c910414a1ca63a",
                "md5": "3f9c405a17ab7823c16c7109c4a070bc",
                "sha256": "dc2fd816a96e32586afb6507f01de6070a8a50877207ae20efa7c6a75648143a"
            },
            "downloads": -1,
            "filename": "poetry_dotenv_plugin-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f9c405a17ab7823c16c7109c4a070bc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4",
            "size": 4002,
            "upload_time": "2023-07-16T11:35:45",
            "upload_time_iso_8601": "2023-07-16T11:35:45.530960Z",
            "url": "https://files.pythonhosted.org/packages/74/60/85248a2c3a983e9052fe1458e88ceb524a882dc718f223c910414a1ca63a/poetry_dotenv_plugin-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f7a6f329eee5b9e57669f00c12b6d2b811dc1b394741518f967a3ed75131dc8",
                "md5": "bbeb889deb9f5f4bdeb6a9fe3bc0d0c5",
                "sha256": "9bdd0a96d81ba5f2e75bda7c8944e2c5132b0c615c44452770dd1e7f1aca62f6"
            },
            "downloads": -1,
            "filename": "poetry_dotenv_plugin-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bbeb889deb9f5f4bdeb6a9fe3bc0d0c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4",
            "size": 2977,
            "upload_time": "2023-07-16T11:35:46",
            "upload_time_iso_8601": "2023-07-16T11:35:46.795618Z",
            "url": "https://files.pythonhosted.org/packages/8f/7a/6f329eee5b9e57669f00c12b6d2b811dc1b394741518f967a3ed75131dc8/poetry_dotenv_plugin-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-16 11:35:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mpeteuil",
    "github_project": "poetry-dotenv-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "poetry-dotenv-plugin"
}
        
Elapsed time: 0.12991s