Skip to main content

EdgeKit: Cloudflare Workers Python native SDK and builder toolkit

EdgeKit has two jobs:

  1. Provide a small Python-first API for writing Workers Python.
  2. Build a runtime bundle by analyzing your project, tree-shaking, vendoring dependencies.

What EdgeKit Provides

  • WorkerEntrypoint[Env] for typed Worker classes
  • Request, Response, Headers, and URL wrappers around the Workers Web APIs
  • Typed binding wrappers for:
    • static assets
    • D1
    • KV
    • R2
    • Queues
    • Durable Objects
  • WSGI and ASGI adapters for framework integration
  • A CLI for:
    • project analysis
    • risk checks for tree-shaking and bundling
    • bundle emission
    • report rendering

Requirements

  • Python >=3.12
  • uv for 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

Metadata

Release files for edgekit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edgekit 0.1.1
File Size Uploaded Provenance Actions
edgekit-0.1.1.tar.gz 104.3 kB Without provenance Details for edgekit-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for edgekit 0.1.1
File Interpreter ABI Platform Actions
edgekit-0.1.1-py3-none-any.whl Python 3 none any Details for edgekit-0.1.1-py3-none-any.whl

Total release size: 185.1 kB

Release files / edgekit-0.1.1.tar.gz

Download URL edgekit-0.1.1.tar.gz
Size 104.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a23810a4cf5b50e11359fb637c73fe8d2f18aaa089f669b7c8512ad2c580d8d3
BLAKE2b-256 checksum
How to use checksums
dfc7f5578ce6587dbf4f9c64690e7079f75ca19c4337b8394e792803b6859da5
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / edgekit-0.1.1-py3-none-any.whl

Download URL edgekit-0.1.1-py3-none-any.whl
Size 80.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5de7ea5cae5eab72310b62d104a20ece2ae9bdc25b4898ddd5f518e26d568ad2
BLAKE2b-256 checksum
How to use checksums
3789cda88c8094a667b9a64f8a6497f52baed52486a89436cc55b66dd2182171
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for edgekit 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page