A Python library for boilerplate-free configuration using environment variables. Current version 24.1.0 (released 2024-10-27) with type annotations, minimal setup, and a decorator-based approach. Maintenance release with tests/docs updates.
Install & Compatibility
Where this runs
tested against v24.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.118s · 18.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.114s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
The package name on PyPI is 'environ-config' but the import module is 'environ'. Using 'environ_config' will raise ModuleNotFoundError.
import environ
Common but the correct way is to import the config class directly. Both work, but direct import is idiomatic.
from environ import config
Define a configuration class with a decorator. Annotate fields; they are automatically populated from environment variables with the given prefix. Defaults are allowed.
import os
from environ import config
@config
class MyConfig:
prefix = 'MYAPP'
host: str
port: int = 8080
cfg = MyConfig()
print(f'Host: {cfg.host}, Port: {cfg.port}')
os.environ['MYAPP_HOST'] = 'example.com'
os.environ['MYAPP_PORT'] = '9090'
cfg2 = MyConfig()
print(f'Host: {cfg2.host}, Port: {cfg2.port}')
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.