Managing environment config data
Project description
py-envconfig ⚙️
Managing config data from the environment, inspired by envconfig
Install
pip install py-envconfig
Usage
Set some environment variable, or write a .env
file.
HOST=localhost
PORT=6000
MY_APP_SERVICE=bookings
RELEASE_NUMBER=12
ENV=dev
Then specify your config:
from envconfig import param
from envconfig import EnvConfig
class AppConfig(EnvConfig):
"""App env config."""
HOST = param.Str(required=True)
PORT = param.Int(required=True)
PASSWORD = param.Str(override="SECRET_REDIS_PW", required=True)
SERVICE = param.Str(prefix="MY_APP_")
VERSION = param.Int(override="RELEASE_NUMBER")
ENV = param.Str(default="prod")
config = AppConfig()
# Access by class attribute or subscript
config.USER
config["USER"]
Setup flask config:
config = AppConfig()
app.config.from_object(config)
Point to a .env
file
config = AppConfig("./.env")
Development
Testing
pytest tests/
Package and Distributing
Create package
rm -rf dist/
python setup.py sdist bdist_wheel
Upload to package index
python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-envconfig-0.2.0.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for py_envconfig-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 348e05b1ebca31087c8d78362279593e32e279558626232ba62b709bc596f2f1 |
|
MD5 | beab38178ddb03032c6113913c1bdbf2 |
|
BLAKE2b-256 | a8c8c5dde37d066cb0e060f4c8d47268f376ee519411e78329c0c66fb834c6c5 |