Skip to content
Cloudflare Docs

Packages

Pywrangler is a CLI tool for managing packages and Python Workers. It is meant as a wrapper for wrangler that sets up a full environment for you, including bundling your packages into your worker bundle on deployment.

To get started, create a pyproject.toml file with the following contents:

[project]
name = "YourProjectName"
version = "0.1.0"
description = "Add your description here"
requires-python = ">=3.12"
dependencies = [
"fastapi"
]
[dependency-groups]
dev = ["workers-py"]

The above will allow your worker to depend on the FastAPI package.

To run the worker locally:

uv run pywrangler dev

To deploy your worker:

uv run pywrangler deploy

Your dependencies will get bundled with your worker automatically on deployment.

The pywrangler CLI also supports all commands supported by the wrangler tool, for the full list of commands run uv run pywrangler --help.

Supported Libraries

Python Workers support pure Python packages on PyPI, as well as packages that are included in Pyodide.

If you would like to use a package that is not pure Python and not yet supported in Pyodide, request support via the Python Packages Discussions on the Cloudflare Workers Runtime GitHub repository.

HTTP Client Libraries

Only HTTP libraries that are able to make requests asynchronously are supported. Currently, these include aiohttp and httpx. You can also use the fetch() API from JavaScript, using Python Workers' foreign function interface to make HTTP requests.