Skip to main content

Managing environment config data

Project description

py-envconfig ⚙️

Managing config data from the environment, inspired by envconfig

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")

Load Dotenv

Some functionality provided by dotenv

  • Increase verbosity

    AppConfig(verbose=True)
    
  • Override existing env vars with the env vars defined in .env.

    AppConfig(override=True)
    

Development

To publish package and tag git:

make tag

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for py-envconfig, version 0.6.0
Filename, size File type Python version Upload date Hashes
Filename, size py_envconfig-0.6.0-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py-envconfig-0.6.0.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page