-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding automatic loading of .env file #339
Conversation
workdir_path = Path(os.getcwd()) | ||
env_file_path = workdir_path / ".env" | ||
if env_file_path.is_file(): | ||
load_dotenv(env_file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be overthinking it but if we did something like
read_dotenv = dotenv.get_key(env_file_path, 'POETRY_READ_DOTENV')
if read_dotenv is None or read_dotenv.lower() not in ('false', 'n', 'no', 'off', '0'):
load_dotenv(env_file_path)
This gives users a way to turn off reading the .env file into the os.environ on a per-directory basis even if we have a global setting that turns it on?
|
||
|
||
def load_dotenv_if_exists(): | ||
workdir_path = Path(os.getcwd()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth adding a settings.commands.dotenv
(or better named) config setting here- as you suggested it would let people set it to an alternative filename (i.e. poetry.env
). setting it to empty / false could turn it off globally?
lgtm 👍 |
Maybe rebase is better than merging develop? It makes history much cleaner. $ git remote update
$ git rebase -i upstream/develop |
Hey, what's the status of this? |
Closing this since I have mentioned in #337 that this is beyond the scope of Poetry |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
This is in support of #337, it doesn't include tests but I didn't find any for the
run
andshell
command. I'll defer to your decision on if I should add tests, what kind of test, or if it can wait.I feel like eventually a config value to change the name of the file to load instead of hardcoding.env
could be nice but may not be needed now.