EdgeKit has two jobs:
- Provide a small Python-first API for writing Workers Python.
- Build a runtime bundle by analyzing your project, tree-shaking, vendoring dependencies.
WorkerEntrypoint[Env]for typed Worker classesRequest,Response,Headers, andURLwrappers around the Workers Web APIs- Typed binding wrappers for:
- static assets
- D1
- KV
- R2
- Queues
- Durable Objects
WSGIandASGIadapters for framework integration- A CLI for:
- project analysis
- risk checks for tree-shaking and bundling
- bundle emission
- report rendering
- Python
>=3.12 uvfor dependency management- wrangler CLI for development and deployment
Install Python and Node dependencies in the repository root:
uv syncUseful commands:
edgekit analyze
edgekit doctor
edgekit build
npm run devThe root wrangler.jsonc should be configured to call edgekit build before wrangler dev.
Initialize a new project first:
uvx --from workers-py==1.9.1 pywrangler init # the latest version of workers-py, v1.9.2, is causing errors at the moment
cd <your-project>
uv add edgekitThe minimal Worker shape looks like this:
from edgekit import Request, Response, WorkerEntrypoint
class Default(WorkerEntrypoint):
async def fetch(self, request: Request) -> Response:
return Response.json(
{
"ok": True,
"method": request.method,
"pathname": request.url.pathname,
}
)Set the Worker entrypoint in pyproject.toml:
[tool.edgekit.builder]
entry = "src/app.py"
compatibility_date = "2026-04-13"Then point Wrangler at the built output:
Run:
wrangler devEdgeKit can bind the Workers env object to a typed Python protocol or class.
from typing import Protocol
from edgekit import Request, Response, WorkerEntrypoint
from edgekit.bindings import D1Database, StaticAssets
class Env(Protocol):
ASSETS: StaticAssets
DB: D1Database
class Default(WorkerEntrypoint[Env]):
async def fetch(self, request: Request) -> Response:
ok = await self.env.DB.prepare("select 1 as ok").first("ok", type=int)
asset = await self.env.ASSETS.fetch("/hello.txt")
return Response.json(
{
"ok": ok if ok is not None else 0,
"asset": await asset.read_text(),
}
)edgekit.runtime exports two helpers:
current_env([EnvType])- Returns the active env object for the current request scope.
- Used by adapters such as WSGI and ASGI to expose the current Worker env inside framework code.
await_sync(awaitable)- Runs an awaitable synchronously via Pyodide runtime bindings.
Example:
from typing import Protocol
from edgekit.adapters import WSGI
from edgekit.bindings import StaticAssets
from edgekit.runtime import await_sync, current_env
class Env(Protocol):
ASSETS: StaticAssets
def read_asset_text(path: str) -> str:
env = current_env(Env)
response = await_sync(env.ASSETS.fetch(path))
return await_sync(response.read_text())MIT License
{ "main": "build/edgekit/wrangler/python_modules/app.py", "compatibility_date": "2026-04-13", "compatibility_flags": ["python_workers"], "build": { "command": "uv run edgekit build", }, }