environ_config: Configuration with env variables for Python.
environ_config allows you to configure your applications using environment variables – as recommended in The Twelve-Factor App methodology – with elegant, boilerplate-free, and declarative code:
>>> import environ
>>> # Extracts secrets from Vault-via-envconsul: 'secret/your-app':
>>> vault = environ.secrets.VaultEnvSecrets(vault_prefix="SECRET_YOUR_APP")
>>> @environ.config(prefix="APP")
... class AppConfig:
... @environ.config
... class DB:
... name = environ.var("default_db")
... host = environ.var("default.host")
... port = environ.var(5432, convert=int) # Use attrs's converters and validators!
... user = environ.var("default_user")
... password = vault.secret()
...
... env = environ.var()
... lang = environ.var(name="LANG") # It's possible to overwrite the names of variables.
... db = environ.group(DB)
... awesome = environ.bool_var()
>>> cfg = environ.to_config(
... AppConfig,
... environ={
... "APP_ENV": "dev",
... "APP_DB_HOST": "localhost",
... "LANG": "C",
... "APP_AWESOME": "yes", # true and 1 work too, everything else is False
... # Vault-via-envconsul-style var name:
... "SECRET_YOUR_APP_DB_PASSWORD": "s3kr3t",
... }) # Uses os.environ by default.
>>> cfg
AppConfig(env='dev', lang='C', db=AppConfig.DB(name='default_db', host='localhost', port=5432, user='default_user', password=<SECRET>), awesome=True)
>>> cfg.db.password
's3kr3t'
Features
Declarative & boilerplate-free.
Nested config from flat env variable names.
Default & mandatory values: enforce configuration structure without writing a line of code.
Helpful debug logging that will tell you which variables are present and what environ_config is looking for.
Built on top of attrs which gives you data validation and conversion for free.
Plugable secrets extraction. Ships with:
HashiCorp Vault support via envconsul.
INI files, because secrets in env variables are icky.
Project Information
environ_config is released under the MIT license. It targets Python 2.7, 3.5 and newer, and PyPy.
Release Information
17.1.0 (2017-12-14)
Initial release.
Credits
environ_config is written and maintained by Hynek Schlawack.
The development is kindly supported by Variomedia AG.
A full list of contributors can be found in GitHub’s overview.
environ_config wouldn’t be possible without the attrs project.
Metadata
Release files for environ-config 17.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| environ_config-17.1.0.tar.gz | 10.2 kB | Without provenance | Details for environ_config-17.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| environ_config-17.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for environ_config-17.1.0-py2.py3-none-any.whl |
Total release size: 19.9 kB
Release files / environ_config-17.1.0.tar.gz
| Download URL | environ_config-17.1.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff8b466eb4fe192c04ed672430bc8cfd9d4ee087536554f928010bf94c161fbe
|
|
BLAKE2b-256 checksum How to use checksums |
a436182c10ec64cf3effe2b0f80d21a889c15aceb90308d9f5722d914852a655
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / environ_config-17.1.0-py2.py3-none-any.whl
| Download URL | environ_config-17.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
aec5d85a7d0bb788c01c13fe537e0628b175dafb67a5cc5650ed5f407c3e5508
|
|
BLAKE2b-256 checksum How to use checksums |
04434b79076e141761f3b069a11c3095f706ca32bba16230b67287cecf401530
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for environ-config 17.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.