-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add support for python-dotenv at the config level #1000
Comments
I see no harm in checking for the existence of this file when loading a project, and processing it if it's found. |
Would it make sense if the value of the |
Ooooo. That's much better |
Cool. And @iamdefinitelyahuman, do you think the dotenv file should be a) auto-loaded, or b) loaded only if |
I vote for loading only if it's specified. |
Loading only if explicitly opted in via the YAML config sounds better to me. Sort of how docker-compose allows one to load an env-file or multiple. Plus, security wise might be better to opt-in 🤔 https://docs.docker.com/compose/environment-variables/#the-env_file-configuration-option |
I agree. I'd just like to get buy-in from @iamdefinitelyahuman before building something out. When it comes to crypto projects, I'm an advocate for configuration over convention. Writing an extra line in a config file is a great price to pay, especially if it means avoiding unexpected configuration behavior. |
Sounds good to me! I agree that the explicitness of adding a line to the config is better than potential accidentally... some config settings. |
Excellent. Another realization is that this should probably support interpolating envvars in the config, like this:
|
@iamdefinitelyahuman I have something basic up, but 1) it's not quite working yet, and 2) I'm still thinking about what should be in charge of loading the env file. It seems like a responsibility of That said, if we do want to support POSIX-style variable interpolation, we'd probably want access in the ConfigContainer level so that we only have to parse once. Thoughts? |
Yes. 100%. This was something that I was surprised didn't work by default. This will be a massive improvement adding that to the yaml. |
As I didn't see this mentioned previously, direnv is an alternative to having brownie process Its a tradeoff between suggesting users install a separate tool and increasing the amount of things brownie needs to do. |
Makes sense. I can add this in; should be pretty straightforward. Sorry for the delay, recently made the |
Congratulations!! |
Overview
I'd love to see brownie support a
.env
file for environment variables. For new engineers, or a project that doesn't want to keep a ton of environment variables running, a.env
file is a warm welcome. Truffle and Hardhat (the javascript smart contract frameworks) have really nice config files that allow them to work with .env files. A bit of a quality of life improvement.Otherwise, we have to call in the
.env
file in all our script manually, seems pretty redundant to do so.Specification
Not sure how this is normal done in yaml, but would like to see something like:
dotenv: true
And then they can load via a
.env
file. We could just use https://pypi.org/project/python-dotenv/ to load at the start of all the scripts.Dependencies
https://pypi.org/project/python-dotenv/
What do we think?
The text was updated successfully, but these errors were encountered: