Giter Site home page Giter Site logo

adriandsg / poetry-dotenv-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mpeteuil/poetry-dotenv-plugin

0.0 0.0 0.0 20 KB

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

License: MIT License

Shell 71.96% Python 28.04%

poetry-dotenv-plugin's Introduction

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+1

$ 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.2

Footnotes

  1. Python 3.7 is supported only when using Poetry < 1.6.0, which dropped support for Python 3.7.

  2. See #16 for background.

poetry-dotenv-plugin's People

Contributors

mpeteuil avatar nnsnodnb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.