MotherNature: A Framework-Agnostic Python Environment Variables Manager

In today's fast-paced tech startup environment you need to ship things fast. This makes way to the blossoming continuous integration and code promotion system.
Continuous integration and code promotion have several requirements. One of it is environment variables management. This will enable your code promotion easier. Change your environments and you still get the correct values. 
In python world there are tools for this but most of it are tailored to certain frameworks. Take Flask-Environments and Django-Environ. These solutions does not always work everywhere.
About 4 months ago, the app I worked on requires me to use Apache Thrift. The public facing API is using Flask. I can use Flask-Environments. But, the micro-services are build using standard Thrift Servers. These babies do not have any environment variables manager. This was when I decided that I should write my own.
Enter MotherNature, a framework agnostic python environment variables manager. It comes with several functionalities that are battle tested.
To install it you need to run:
easy_install mothernature
Or if you prefer pip:
pip install mothernature
To use it you need to define a .yaml file with the following structure:

And then in your code, all you need is:

With this, when you start your app simply run:
python app.py [desired env]
You can also define default environments. Simply set the optional environment parameter int the constructor so it becomes

With the second approach, when you start the app without the desired environment argument it will use the default environment.

I made this with simplicity in mind. Just like MotherNature takes care of the environment, so does this library. MotherNature is designed to make environment management easy using a single .yaml file.

Hope this can help you manage your environment variables better. The GitHub repo is at https://github.com/femmerling/mothernature. Feel free to post issues or submit pull requests there.

regards

-E-

follow @femmerling on twitter
visit my website

Comments

Popular posts from this blog

Customizing Sanic's Logging output on Gunicorn

Bali: A view from an Indonesian

5 Takeaways From My Past 5 Years With Coral, Prism, Midtrans and Gojek