Búvár
This is heavily inspired by Pyramid and my daily needs to fastly create and maintain microservice like applications.
Requires Python 3.14 or newer.
a plugin mechanic
plugin may depend on other plugins
plugins yield tasks to run
a context registry serves as a store for application components created by plugins
a dependency injection creates intermediate components
a config source is mapped to plugin specific configuration and may be fully overridden by environment vars
structlog boilerplate for json/tty logging
fork the process and share bound sockets
pytest fixtures to reduce testing boilerplate
You bootstrap like following:
from buvar import plugin
plugin.stage("some.module.with.prepare")
# some.module.with.prepare
from buvar import context, plugin
class Foo:
...
async def task():
asyncio.sleep(1)
async def server():
my_component = context.get(Foo)
await asyncio.Future()
# there is also plugin.Teardown and plugin.Cancel
async def prepare(load: plugin.Loader):
await load('.another.plugin')
# create some long lasting components
my_component = context.add(Foo())
# you may run simple tasks
yield task()
# you may run server tasks
yield server()
a components and dependency injection solution
Dependency injection relies on registered adapters, which may be a function, a method, a class, a classmethod or a generic classmthod.
Dependencies are looked up in components or may be provided via kwargs.
from buvar import di
class Bar:
pass
class Foo:
def __init__(self, bar: Bar = None):
self.bar = bar
@classmethod
async def adapt(cls, baz: str) -> Foo:
return Foo()
async def adapt(bar: Bar) -> Foo
foo = Foo(bar)
return foo
async def task():
foo = await di.nject(Foo, baz="baz")
assert foo.bar is None
bar = Bar()
foo = await di.nject(Foo, bar=bar)
assert foo.bar is bar
async def prepare():
di.register(Foo.adapt)
di.register(adapt)
yield task()
a config source
buvar.config.ConfigSource is just a dict, which merges
arbitrary dicts into one. It serves as the single source of truth for
application variability.
You can load a section of config values into your custom attrs class instance. ConfigSource will override values by environment variables if present.
config.toml
log_level = "DEBUG"
show_warnings = "yes"
[foobar]
some = "value"
export APP_FOOBAR_SOME=thing
import attr
import toml
from buvar import config
@attr.s(auto_attribs=True)
class GeneralConfig:
log_level: str = "INFO"
show_warnings: bool = config.bool_var(False)
@attr.s(auto_attribs=True)
class FoobarConfig:
some: str
source = config.ConfigSource(toml.load('config.toml'), env_prefix="APP")
general_config = source.load(GeneralConfig)
assert general_config == GeneralConfig(log_level="DEBUG", show_warnings=True)
foobar_config = source.load(FoobarConfig, 'foobar')
assert foobar_config.some == "thing"
There is a shortcut to the above approach provided by
buvar.config.Config, which requires to be subclassed from it with a
distinct section attribute. If one adds a buvar.config.ConfigSource
component, he will receive the mapped config in one call.
from buvar import config, plugin
@attr.s(auto_attribs=True)
class GeneralConfig(config.Config):
log_level: str = "INFO"
show_warnings: bool = config.bool_var(False)
@attr.s(auto_attribs=True)
class FoobarConfig(config.Config, section="foobar"):
some: str
async def prepare(load: plugin.Loader):
# this would by typically placed in the main CLI entry point
source = context.add(config.ConfigSource(toml.load('config.toml'), env_prefix="APP"))
# to provide the adapter to di, which could also be done in the main entry point
await load(config)
foobar_config = await di.nject(FoobarConfig)
a structlog
Just structlog boilerplate.
import sys
from buvar import log
log_config = log.LogConfig(tty=sys.stdout.isatty(), level="DEBUG")
log_config.setup()
pytest
There are a couple of pytest fixtures provided to get your context into a reasonable state:
buvar_config_sourceA
dictwith arbitrary application settings.buvar_contextThe basic context staging operates on.
buvar_stageThe actual stage processing all plugins.
buvar_loadThe loader to add plugins to the stage.
buvar_plugin_contextThe context all plugins share, when they are prepared.
Following markers may be applied to a test
buvar_plugins(plugin, ...)Load all plugins into plugin context.
import pytest
async def prepare():
from buvar import context
context.add("foobar")
@pytest.mark.asyncio
@pytest.mark.buvar_plugins("tests.test_testing")
async def test_wrapped_stage_context():
from buvar import context, plugin
assert context.get(str) == "foobar"
assert context.get(plugin.Cancel)
@pytest.mark.asyncio
@pytest.mark.buvar_plugins()
async def test_wrapped_stage_context_load(buvar_load):
from buvar import context, plugin
await buvar_load(prepare)
assert context.get(str) == "foobar"
assert context.get(plugin.Cancel)
Metadata
Release files for buvar 0.44.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| buvar-0.44.19.tar.gz | 34.1 kB | Details |
Built distributions (wheels)
Total release size: 5.1 MB
Release files / buvar-0.44.19.tar.gz
| Download URL | buvar-0.44.19.tar.gz |
|---|---|
| Size | 34.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b851120eaaeffb102ffd6c3394bddb5311c4a91c82d92ab90ebeb417200c8c9e
|
|
BLAKE2b-256 checksum How to use checksums |
248cd2888db7a97f64d5970a6e45b1803ab9a321087bc2bf75eb445bd80e9b1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314t-musllinux_1_2_x86_64.whl
| Download URL | buvar-0.44.19-cp314-cp314t-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 645.8 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
2116e2aa9c86316c06b988388b23e2b611a60c1c2548611711832c2d6cb88c5a
|
|
BLAKE2b-256 checksum How to use checksums |
ff7ed7df22579ca1ffc0a0e385b71159a61d8536600f87ad21d970f6bd60ae44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314t-musllinux_1_2_aarch64.whl
| Download URL | buvar-0.44.19-cp314-cp314t-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 643.1 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
6397e980f8fbf142186860c8c9fcea4d88efde2c9fdd26617087d93de004f917
|
|
BLAKE2b-256 checksum How to use checksums |
089fc3d6689cc0e84da51e7b9d2a065c7db398ad7c7d41b61f6fc369f9f16ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | buvar-0.44.19-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 668.0 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
f7a0e33630e716b0a3914b2a522a445427f0198acfe2d4fda705103c946d6f5d
|
|
BLAKE2b-256 checksum How to use checksums |
5a276293dc2ac97a6c1afe56e6b738df13c1cce83a29e08ebf2fe53110bdaee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | buvar-0.44.19-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 652.1 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
f21cf9f588cd6c48a9bd69ba054e1d4e94bc67a784cf071ce67f6f0581942d22
|
|
BLAKE2b-256 checksum How to use checksums |
1d5646f36b636749f2e39abf50fe7410f08d0315d4a6b283abe22a9c4890ed4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | buvar-0.44.19-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 119.1 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
382feed39c647b5dae2370989e6224da4c42f4395e0426f0be64403e8a868fc4
|
|
BLAKE2b-256 checksum How to use checksums |
cd5bf6c63a1689303fb2b9709e86433896930cd64a1a8e34fbed4ce78fc1b356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | buvar-0.44.19-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 561.9 kB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
0b3cdff07d0358ff9da1d81fe33c0d27e15ce78a01005dc489468c83712ff790
|
|
BLAKE2b-256 checksum How to use checksums |
67ae2db569ae60c7bf9972ee6752d9cf5d2a0aa26b84b8f969d20fa4c437c5b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314-musllinux_1_2_aarch64.whl
| Download URL | buvar-0.44.19-cp314-cp314-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 546.7 kB |
| Tags | CPython 3.14 Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
1daa72f754f31d6744b983e08c2654101543d542bbb6af734a176056d4bf0757
|
|
BLAKE2b-256 checksum How to use checksums |
ccd328cb1306d20d6fb8c73adfdff4eace93e0f5e69f1785bc5eb0a4fe8984e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | buvar-0.44.19-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 557.8 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
1f657759708d8b4c0676906afe28ea4c0646c708b8ef230b1ec6469f40606abf
|
|
BLAKE2b-256 checksum How to use checksums |
5d106f458fb165ffba61c20cea505fde01f89ecb1ec783cd4e40b6bda76c2a78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | buvar-0.44.19-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 563.0 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
eb2f3d8b2f7e1ecda72813b3f9c5e9e9c63c9552b51a0e30dc022d39619039cb
|
|
BLAKE2b-256 checksum How to use checksums |
2e790aefb4f9b5ef050babdf2d954dd5e45327e3d9ba16f85f73ab1c14fb6b31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency logRelease files / buvar-0.44.19-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | buvar-0.44.19-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 109.8 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1448f2f179f10435775894648d075bf83760dc5bc9799246bcd8b2b0614d8057
|
|
BLAKE2b-256 checksum How to use checksums |
a1d7dd349c1aa75aa121072855a851497c225f25093432f0ca5b8b1a518150b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.
Transparency log