Engin 🏎️
Documentation: https://engin.readthedocs.io/
Source Code: https://github.com/invokermain/engin
Engin is a lightweight application framework powered by dependency injection. It helps you build and maintain everything from large monoliths to hundreds of microservices.
Features
Engin provides:
- A fully-featured dependency injection system.
- A robust runtime with lifecycle hooks and supervised background tasks.
- Zero-boilerplate code reuse across applications.
- Integrations for popular frameworks like FastAPI.
- Full asyncio support.
- A CLI for development utilities.
Installation
Engin is available on PyPI, install it using your favourite dependency manager:
pip install enginpoetry add enginuv add engin
Example
Here’s a minimal example showing how Engin wires dependencies, manages background tasks, and handles graceful shutdown.
import asyncio
from httpx import AsyncClient
from engin import Engin, Invoke, Lifecycle, OnException, Provide, Supervisor
def httpx_client_factory(lifecycle: Lifecycle) -> AsyncClient:
client = AsyncClient()
lifecycle.append(client) # easily manage the AsyncClient's lifecycle concerns
return client
async def main(httpx_client: AsyncClient, supervisor: Supervisor) -> None:
async def long_running_task():
while True:
await httpx_client.get("https://example.org/")
await asyncio.sleep(1.0)
supervisor.supervise(long_running_task) # let the app run the task in a supervised manner
engin = Engin(Provide(httpx_client_factory), Invoke(main)) # define our modular application
asyncio.run(engin.run()) # run it!
Expected output (with logging enabled):
[INFO] engin: starting engin
[INFO] engin: startup complete
[INFO] engin: supervising task: long_running_task
[INFO] httpx: HTTP Request: GET https://example.org/ "HTTP/1.1 200 OK"
[INFO] httpx: HTTP Request: GET https://example.org/ "HTTP/1.1 200 OK"
[INFO] httpx: HTTP Request: GET https://example.org/ "HTTP/1.1 200 OK"
[DEBUG] engin: received signal: SIGINT
[DEBUG] engin: supervised task 'long_running_task' was cancelled
[INFO] engin: stopping engin
[INFO] engin: shutdown complete
Inspiration
Engin is heavily inspired by Uber's Fx framework for Go and the Injector framework for Python.
They are both great projects, go check them out.
Benchmarks
Automated performance benchmarks for Engin are available here.
Metadata
Release files for engin 0.4.1
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 |
|---|---|---|---|---|
| engin-0.4.1.tar.gz | 31.8 kB | Without provenance | Details for engin-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| engin-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for engin-0.4.1-py3-none-any.whl |
Total release size: 70.9 kB
Release files / engin-0.4.1.tar.gz
| Download URL | engin-0.4.1.tar.gz |
|---|---|
| Size | 31.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8acd17ce4dec1fcf332e19596dcbadc70b9289f518344176baac07925a4fd55
|
|
BLAKE2b-256 checksum How to use checksums |
317ab8ac5ffeff93a7e2560535da6b9e09686f6638f89ce958c6e4ff11f5a94c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / engin-0.4.1-py3-none-any.whl
| Download URL | engin-0.4.1-py3-none-any.whl |
|---|---|
| Size | 39.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54046c80a4ae5c0f8d06d7fa4936dab7b5425eddf97c9a52b599d3d8cff14f59
|
|
BLAKE2b-256 checksum How to use checksums |
acae4b0ef5731674e8f45767fd29ada6b0d28c0857cbd6368fada366b22cdbcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for engin 0.4.1
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.