Skip to main content

Settings management, pluggable secrets, and run-scoped logging for Python applications.

Project description

Konfig

Settings management, pluggable secrets, and run-scoped logging for Python applications.

Konfig provides three foundational capabilities every Python application needs, with an optional lightweight app lifecycle context manager that ties them together. It is a clean-sheet replacement for dtPyAppFramework.

Features

  • Layered settings with system/user/env/runtime precedence and persistent writes
  • Pluggable secrets with OS keyring, AES-encrypted file, and AWS Secrets Manager backends
  • Run-scoped logging with historical retention, structured JSON mode, and stdio-safe output
  • Platform-aware defaults for config, data, and log directories (macOS, Linux, Windows)
  • Optional app lifecycle via a sync/async context manager — no inheritance required
  • Python 3.10+

Installation

pip install konfig

For AWS Secrets Manager support:

pip install konfig[aws]

Quick Start

from konfig import AppContext

with AppContext(
    name="My Application",
    version="1.0.0",
    config_file="config.yaml",
    env_prefix="MYAPP",
) as ctx:
    host = ctx.settings.get("database.host", "localhost")
    api_key = ctx.secrets.get("api_key")
    ctx.logger.info("Starting with host=%s", host)

For async applications:

async with AppContext(name="My Server", version="2.0.0") as ctx:
    await run_server(ctx.settings)

Each subsystem (Settings, Secrets, LogManager) can also be used independently. See the full documentation in the docs/ directory:

Samples

Working examples are provided in the samples/ directory:

File Description
basic_settings.py Config files, defaults, env vars, overrides
secrets_usage.py Store, retrieve, and delete secrets
logging_demo.py Run-scoped logging with retention
app_context.py Full lifecycle with all subsystems
async_app.py Async context manager usage
custom_backend.py Implementing a custom SecretBackend

Development

pip install -e ".[dev]"
pytest
pytest --cov=konfig
mypy src/konfig
black src/ tests/
isort src/ tests/

License

MIT License. See LICENSE for details.

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

cognisn_konfig-0.1.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cognisn_konfig-0.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file cognisn_konfig-0.1.0.tar.gz.

File metadata

  • Download URL: cognisn_konfig-0.1.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cognisn_konfig-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e169d52fb62f1f99db33a053684af8134efcaeaf900d8112e43b65591c820558
MD5 d755ba0cb6ae41208b457c7423f78959
BLAKE2b-256 fe3657c245132b8ceb1c131761446d3a454cf285d62388c9f306fb4c7b4a52eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cognisn_konfig-0.1.0.tar.gz:

Publisher: publish.yml on Cognisn/konfig

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cognisn_konfig-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cognisn_konfig-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cognisn_konfig-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76f0371bc118cfd1d2523f2003f0e1c7f999b6b408ab2beff97d0bd4cf68e7e2
MD5 24471794a99b8a27d225fcb43bb009fa
BLAKE2b-256 7cbce23cd7472194c7d04c4d0b0e6862af0f0a0b856b54aefe0f6e9b579d0819

See more details on using hashes here.

Provenance

The following attestation bundles were made for cognisn_konfig-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Cognisn/konfig

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page