A library for event sourcing in Python. It provides a framework for building applications using the event sourcing pattern, with support for aggregates, projections, and various persistence backends. Current version is 9.5.4, requiring Python >=3.10. Active development with regular releases.
Install & Compatibility
Where this runs
tested against v9.5.4 · 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.080s · 19.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.074s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Aggregate moved to eventsourcing.domain in v9.
from eventsourcing.domain import Aggregate
Event classes are in eventsourcing.domain.
from eventsourcing.domain import Event
Application has been in eventsourcing.application since early versions.
from eventsourcing.application import Application
LogEvent is part of the domain module.
from eventsourcing.domain import LogEvent
Minimal example: define an aggregate with events, an application, and execute.
import os
from eventsourcing.application import Application
from eventsourcing.domain import Aggregate, event
class Dog(Aggregate):
@event('Registered')
def __init__(self, name):
self.name = name
self.tricks = []
@event('TrickAdded')
def add_trick(self, trick):
self.tricks.append(trick)
class DogSchool(Application):
def register_dog(self, name):
dog = Dog(name)
self.save(dog)
return dog.id
def add_trick(self, dog_id, trick):
dog = self.repository.get(dog_id)
dog.add_trick(trick)
self.save(dog)
def get_dog(self, dog_id):
return self.repository.get(dog_id)
app = DogSchool()
dog_id = app.register_dog('Fido')
app.add_trick(dog_id, 'roll over')
dog = app.get_dog(dog_id)
print(f'{dog.name}: {dog.tricks}')
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.