Cloudflare Workers Python native SDK and builder toolkit
Project description
EdgeKit: Cloudflare Workers Python native SDK and builder toolkit
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.
What EdgeKit Provides
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
Requirements
- Python
>=3.12 uvfor dependency management- wrangler CLI for development and deployment
Local Development
Install Python and Node dependencies in the repository root:
uv sync
Useful commands:
edgekit analyze
edgekit doctor
edgekit build
npm run dev
The root wrangler.jsonc should be configured to call edgekit build before wrangler dev.
Quick Start
Initialize a new project first:
uv run pywrangler init
cd <your-project>
uv add edgekit
The 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:
{
"main": "build/edgekit/wrangler/python_modules/app.py",
"compatibility_date": "2026-04-13",
"compatibility_flags": ["python_workers"],
"build": {
"command": "uv run edgekit build",
},
}
Run:
wrangler dev
Typed Environment Bindings
EdgeKit 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(),
}
)
Runtime Helpers
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())
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edgekit-0.1.1.tar.gz.
File metadata
- Download URL: edgekit-0.1.1.tar.gz
- Upload date:
- Size: 104.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a23810a4cf5b50e11359fb637c73fe8d2f18aaa089f669b7c8512ad2c580d8d3
|
|
| MD5 |
fcb7d97059bf1f2c5adfa260a3064111
|
|
| BLAKE2b-256 |
dfc7f5578ce6587dbf4f9c64690e7079f75ca19c4337b8394e792803b6859da5
|
File details
Details for the file edgekit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: edgekit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 80.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5de7ea5cae5eab72310b62d104a20ece2ae9bdc25b4898ddd5f518e26d568ad2
|
|
| MD5 |
c43f21e37a6639d59ff55cf175fd1de6
|
|
| BLAKE2b-256 |
3789cda88c8094a667b9a64f8a6497f52baed52486a89436cc55b66dd2182171
|